feat: Unit card previews [FC-0083] - #1774
Conversation
|
Thanks for the pull request, @pomegranited! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
rpenido
left a comment
There was a problem hiding this comment.
LGTM 👍
Thank you for your work, @pomegranited!
- I tested this using the instructions from the PR
- I read through the code
- I checked for accessibility issues
- Includes documentation
I left some (non-blocking) comments.
| /** | ||
| * Get the URL for a single container children api. | ||
| */ | ||
| export const getLibraryContainerChildrenApiUrl = (containerId: string) => `${getApiBaseUrl()}/api/libraries/v2/containers/${containerId}/children/`; |
There was a problem hiding this comment.
I think this is ok for now, but we should put this info in our index. Each of these calls took almost 2 sec on my stack.
Since we don't have the children's info on the index yet (and don't plan to have it soon), we could store an array with the first N types on the Unit document, like you did here in the frontend.
What do you think?
There was a problem hiding this comment.
I agree we should put the list of child types in the index (can come in a separate PR). But I wonder why each of these calls takes 2 seconds? That seems very slow and it should be super fast considering our unit code is very new and supposedly lightweight.
There was a problem hiding this comment.
I think it is because I had a lot of concurrent requests?

Also, we are iterating through the records here:
https://github.com/openedx/openedx-learning/blob/a79b579fd3f91c763d193c2e6841fb7f9f4796c7/openedx_learning/apps/authoring/units/api.py#L245-L267
There was a problem hiding this comment.
Created a followup task to fix this: #1778
There was a problem hiding this comment.
we are iterating through the records here:
https://github.com/openedx/openedx-learning/blob/a79b579fd3f91c763d193c2e6841fb7f9f4796c7/openedx_learning/apps/authoring/units/api.py#L245-L267
Perhaps we are missing a select_related then. Iterating through the records should still be fast, as long as there are no database queries within the loop. Perhaps we need to select_related on entry.entity_version.componentversion outside the loop before accessing it inside the loop.
e115fa3 to
e81c973
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1774 +/- ##
=======================================
Coverage 93.49% 93.50%
=======================================
Files 1128 1128
Lines 22882 22908 +26
Branches 4963 4951 -12
=======================================
+ Hits 21394 21419 +25
- Misses 1412 1421 +9
+ Partials 76 68 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChrisChV
left a comment
There was a problem hiding this comment.
Looks good! I will merge it on Monday morning
|
@pomegranited Could you fix the conflicts? |
|
@ChrisChV Conflicts fixed -- ready for your merge :) |
and remove a line accidentally added when resolving conflicts.
Adds block tiles to the Unit card to indicate type and quantity of children in the container.
Description
Adds block tiles to the Unit card to indicate type and quantity of children in the container.
This feature affects Library Authors.
Supporting information
Part of: #1618
Includes one commit borrowed from #1762
Private-ref: FAL-4057
Testing instructions
Run latest edx-platform
masterIn the Authoring MFE:
Click the Unit to get its locator key from the URL, starting with
lct:Add child blocks using the shell:
tutor dev exec cms ./manage.py cms shell:Back in the Authoring MFE:
Maximum 5 blocks should be shown, with <4 showing as 4 blocks and "+N".
Other information
I had to give the cards a minimum width of
15remto ensure 5 block tiles would fit.