-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide "Show all editions" link in edition table when appropriate #10017
Hide "Show all editions" link in edition table when appropriate #10017
Conversation
The issue#9946 was occurring due to "?mode=ebooks" being default at some point in time earlier. Since that is not the case anymore, according to the openlibrary/openlibrary/templates/type/edition/view.html, the editions_limit was being assigned the value 10 always. This prevented the default value of editions_limit to be None (which is then used in openlibrary/openlibrary/templates/type/work/editions_database.html). The change includes the 'None' to be one of the acceptable states, restoring the originally intended logic.
@SivanC would you be able to give this one a code review and QA? |
Sweet ty! Haha, I needed you to leave a comment, otherwise GitHub won't let me assign you 😁 |
@SivanC waiting for it to be merged! |
@Spaarsh Thanks for reaching out! Unfortunately I'm not in a position to be able to merge your PR, but I will contact those who can again and see that it gets merged soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience, @Spaarsh!
When I deployed this to our testing environment today, I noticed that the featured edition counts and the table entries for some book pages were different in production.
Work OL77764W in production environment
Work OL77764W in testing environment
If mode
exists, then we expect it to be either all
or ebooks
. Because of this, these changes effectively set limit
to None
every time the page is loaded (the exception being when mode
is manually set to an unexpected value, like baz
).
Limiting the number of editions that we fetch for a book page is very important, especially when the work has several hundred editions. Page rendering is blocked by the get_sorted_editions
call, and waiting for this method to return can take tens of seconds in the worst case.
Can you roll this change back, and instead update this condition in editions_datatable.html
? I think that something like this would work:
(editions_limit and len(editions) < editions_limit) or (len(editions) < work.edition_count)
…editions-in-editions-table-when-not-necessary
This reverts commit 5f45188.
Sorry for the delay! The change suggested by you didn't work, so made one small change, I flipped the less than sign to a greater sign:
Explanation:The editions_limit is set to None if the mode is ebooks or all, otherwise, it is set to be 10 as per this line in view.html. Mode not set or unexpected mode selectedSo, when there is no mode, 10 is the editions_limit, hence the first part of the statement is: Now, if the editions themselves are 8 (as in the case of this work), there is no need to display the "view all editions" part. And accordingly, the statement Moving on to the next part len(edtions) < work.edition_count, when no mode is selected, the len(editions) is equal to the work.edition_count. So the condition return
Mode set to "all" or "ebooks"When the mode is selected to be ebooks or all, the editions_limit is set to None so the first part resolves to a Mode set to "all"Moving to the next part, if the mode==all then len(editions) is equal work.edition_count. Hence the entire condition returns a Mode set to "ebooks"While for the ebooks mode, the len(editions) is less than work.edition_count. Thus the second part of the condition returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Spaarsh! Lgtm.
The issue#9946 was occurring due to "?mode=ebooks" being default at some point in time earlier. Since that is not the case anymore, according to the openlibrary/openlibrary/templates/type/edition/view.html, the editions_limit was being assigned the value 10 always. This prevented the default value of editions_limit to be None (which is then used in openlibrary/openlibrary/templates/type/work/editions_database.html).
The change includes the 'None' to be one of the acceptable states, restoring the originally intended logic.
Closes #9946
fix
Technical
The implementations simply adds None into the set of acceptable states of the query parameter 'mode'.
Testing
Screenshot
Img. 1(when X==Y)
Img. 2 (when X!=Y)
Stakeholders
@SivanC @jimchamp @cdrini