[PR #2896] [MERGED] Split the author call in the library stats page to 2 lighter functions #3819

Closed
opened 2026-04-25 00:17:11 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/2896
Author: @CoffeeKnyte
Created: 4/30/2024
Status: Merged
Merged: 5/8/2024
Merged by: @advplyr

Base: masterHead: master


📝 Commits (4)

  • 182527b Update LibraryController.js
  • 95cdb23 split getAuthorsWithCount to 2 lighter functions
  • 7229cfc Added limit 10 to getAuthorsWithCount() call
  • 5041f80 Added limit variable to getAuthorsWithCount()

📊 Changes

2 files changed (+35 additions, -21 deletions)

View changed files

📝 server/controllers/LibraryController.js (+2 -2)
📝 server/utils/queries/authorFilters.js (+33 -19)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/2896 **Author:** [@CoffeeKnyte](https://github.com/CoffeeKnyte) **Created:** 4/30/2024 **Status:** ✅ Merged **Merged:** 5/8/2024 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (4) - [`182527b`](https://github.com/advplyr/audiobookshelf/commit/182527bfa88162a31b9908d1145ed81d7c3a542c) Update LibraryController.js - [`95cdb23`](https://github.com/advplyr/audiobookshelf/commit/95cdb23efbab63d3acccc28f0c891f8c3b3403f5) split getAuthorsWithCount to 2 lighter functions - [`7229cfc`](https://github.com/advplyr/audiobookshelf/commit/7229cfce84ada9e9500523344cdd7a63cdf47d84) Added limit 10 to getAuthorsWithCount() call - [`5041f80`](https://github.com/advplyr/audiobookshelf/commit/5041f80cb031bc2006ef3f530eab859f42c90240) Added limit variable to getAuthorsWithCount() ### 📊 Changes **2 files changed** (+35 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `server/controllers/LibraryController.js` (+2 -2) 📝 `server/utils/queries/authorFilters.js` (+33 -19) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:17:11 +02:00
adam closed this issue 2026-04-25 00:17:11 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3819