This repository has been archived by the owner on Dec 27, 2024. It is now read-only.
Return the proper full count from DB queries #496
Merged
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.
Summary 📰
This fixes #495 and effectively reverts #464 which is incorrect.
The UI uses the
count
field to build the navigation between pages, to know how many pages exist, and allow traversing them. #464 broke this, by returningcount
as the number returned entries (an unnecessary value really -.length
would suffice for that).The PR also updates and fixes the tests to reflect this.
The DB logic was slightly refactored to be easier to understand, by having two filter functions (
filterState()
andfilterRange()
), both being used by the main result query, but only the first being used for the count query. This results in a propercount
value.The changeset for #464 says:
This was actually correct. If you only want 1 announcement, it makes perfect sense to return the total number of announcements (i.e. 2) as
count
. It's also necessary for pagination.Checklist ✅
Testing Notes 🔬
To reproduce; Have more announcements than shown in the main page (first page). The bottom page navigation doesn't work. It does with this PR.