openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Paginate Followers & Following pages

Open mekarpeles opened this issue 1 year ago • 2 comments

Currently, the My Followers and Following pages show all a patron's subscribers or subscriptions.

https://openlibrary.org/people/mekBot/followers https://openlibrary.org/people/mekBot/following

Screenshot 2024-05-16 at 6 25 34 AM

If a patron has hundreds or thousands of followers, this likely to cause a significant performance issue. Especially considering #9282.

Open Library has a Pager macro that will automatically handle the UI for adding pagination to a view.

Here is a similar example PR which adds the Pager to a page: #6739

Screenshot 2024-05-16 at 7 13 10 AM

In order to switch from the current system (where all followers / subscriptions are rendered), we'll need to change the code to only fetch 25 per page instead of everything, and then also calculate the total number of pages that exist by querying for the total count of followers and dividing it by 25.

mekarpeles avatar May 16 '24 13:05 mekarpeles

Hello! Could I please work on this issue?

pidgezero-one avatar May 17 '24 22:05 pidgezero-one

Hi @pidgezero-one, sure! Feel free to give it a try and let me know if you have any questions about contributing.

mekarpeles avatar May 18 '24 16:05 mekarpeles

@mekarpeles Is there a recommended way to add 26+ entries to follower/following list for the default (openlibrary) local testing user? I've started a draft PR, but so far I can only verify that the page doesn't break when the list is empty.

(Sorry this took longer than I'd have liked, I picked up this ticket and then got sick!)

pidgezero-one avatar May 23 '24 00:05 pidgezero-one

@pidgezero-one, I don't know that it's a great idea, but I replied on Slack in #openlibrary-g with an idea that may help, or at least get you going in the right direction.

scottbarnes avatar May 24 '24 01:05 scottbarnes

Thank you @scottbarnes! That was exactly what I needed. The PR is ready now thanks to your suggestion.

pidgezero-one avatar May 25 '24 01:05 pidgezero-one