Reduce bitstream authorization requests for item page - #5028
Conversation
|
Please note: I am not a frontend dev, so I would be grateful for a review by a more experienced frontend developer :) especially concerning the revised tests |
|
@tinsch Thanks for the PR! |
|
Any news on this? I think @EikLoe tested it, but did not do a code review. I'm asking because I am not sure if my contribution counts as a feature or a bug fix for DSpace 10. |
|
@tinsch : This would be considered a bug fix. It's still waiting on a code review but is in our "Reviewer Approved" column of the board. I was waiting to see if @artlowel had a chance to take a quick look at it since he previously volunteered. Otherwise, I'll get back to this hopefully in the next week or two. |
There was a problem hiding this comment.
+1 this looks good to me, thanks @tinsch
I can confirm that in item with 60 bitstreams including 8 non-public bitstreams (4 embargoes, 4 totally restricted), I got the request-a-copy links I expected, and the number of requests for the "canRequestACopy" feature were reduced down to 8, after the false canDownload feature was evaluated for each of those bitstreams.
I didn't see quite the stark contrast in page load time in my own local instance (~2800ms vs ~3500ms) but it's definitely quicker and more efficient.
I also confirmed that the links to restricted items work as expected when the Request-a-Copy feature is disabled.
4ef4dc2 to
b156688
Compare
b156688 to
97ebfd8
Compare
|
Thanks @tinsch ! As this is at +2, I think this is ready to merge. The code looks reasonable to me as well. I'm going to attempt to backport this automatically to 9.x (as I think it should work cleanly). Backports to 8.x and 7.x are also welcome, but those are likely to need to be done manually (as the code of this component is a bit different in those releases). If anyone is interested, feel free to create the backport PRs. |
|
Successfully created backport PR for |
|
Thanks @tdonohue! I'll have a look into the 7.x and 8.x codebase and see if a backport is feasible 👍 |
Description
This PR reduces the number of calls to the REST API by executing certain authorization requests only conditionally if the normal download is not possible for the user. Before, the authorization request "canRequestACopy" was always sent for every bitstream, now this only happens if the "canDownload" request returns false. This improves the response time performance for items with a large number of bitstreams and a large pagesize (>=50), as can be seen in a graph below.
Instructions for Reviewers
Currently the response time is slow for items with a large number of bitstreams. The current workaround are small pageSizes for the item's bitstreams per default. However, from a UX standpoint it would be nice to be able to show a larger list of bitstreams to the users, especially in the case of uploaded research data.
How to test this PR:
item.bitstream.pageSizeto 50 (or more)Here is a comparison of the reponse time of an item page, varied in the page size:

Related Issues, former issues with item bitstream pagesize:
DSpace/DSpace#8648
#2065
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).npm run lintnpm run check-circ-deps)package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.Co-funded by the European Union and Universitätsbibliothek TU Berlin (DSpaceQPO project)