fix(media): count whole library for "All Files" total#891
Open
PlusA2M wants to merge 1 commit into
Open
Conversation
GET /admin/media reported `totalFiles: results.length`, but `results` is a single page (LIMIT 24), so the sidebar always read "All Files (24)" and `hasNextPage` compared the page length to the limit. Add a COUNT(*) over the same folder/type filters and derive the total and pagination from it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: PlusA2M <plusa2m@gmail.com>
Collaborator
|
Thanks for this fix! We're in the process of merging v3 to main — v3 has migrated the media module to a document model architecture ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Media library sidebar always shows
All Files (24)because theGET /admin/mediahandler reports the page length as the total. This computes the real total with a
COUNT(*)over the same filters.Fixes #888
Changes
admin-media.tsGET /: add aCOUNT(*)over the same folder/typeconditions(without LIMIT/OFFSET) and use it for
totalFiles.hasNextPagefromoffset + results.length < totalFilesinstead ofcomparing the page length to the limit.
COUNT(*)(not the pagesize), that folder/type filters flow into the count query, and that
hasNextPageis false on the last page.Testing
Unit Tests
admin-media-total-count.test.ts)npm test— full suite green)E2E Tests
Checklist