Skip to content
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

Split the author call in the library stats page to 2 lighter functions #2896

Merged
merged 4 commits into from
May 7, 2024

Conversation

CoffeeKnyte
Copy link
Contributor

Currently on the library stats page, the function getAuthorsWithCount() is called to get both the top 10 authors by number of books, and also the total number of authors in that library. It does this by querying for all authors and every related book. In a library of 30k authors, this query takes 567038ms or around 10 minutes.

This has been split into 2 calls - getAuthorsTotalCount() gets the total number of authors in the library in 1ms and getAuthorsWithCount() only grabs the top 10 authors by number of books written in 35ms. These values will vary based n the number of books in the library, but it represents a significant speed increase.

The results displayed on the stats page should be identical after the change.

used a lighter function to find total author count
getAuthorsWithCount - now only gets the top 10 authors (in that library) by number of books
getAuthorsTotalCount - new function to only get total number of authors (in that library)
- Clarified and updated the comments
- added parameter "limit" to getAuthorsWithCount()
- the limit is set to 10 when called from LibraryController.js
- as per Nichwall's comments
@nichwall
Copy link
Contributor

nichwall commented May 5, 2024

This PR is working for me when tested against my main database.

@advplyr
Copy link
Owner

advplyr commented May 7, 2024

LGTM thanks!

@advplyr advplyr merged commit fd22a6f into advplyr:master May 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants