feat: stop counting the matches of a search at 1001 #121
+85
−7
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
The count of a search (
totalCount) stops at 1001. When a search has more than 1000 matches, the interface shows "1000+" and the database does not count further, so the cost of the count does not grow with the catalog.Part of #110 (the one issue for making the whole Elements page work, in several pull requests). The page that shows "1000+" is in #120; this change is independent of it and goes to
dev.What is in it
backend/src/catalog/search.ts:totalCountiscount({ where, take: max + 1 }).MAX_TOTAL_COUNTis 1000, so a search with more matches gets 1001, which means "more than 1000". A search with 1000 or fewer matches is counted as before.maxTotalCountis an argument, so the tests can try a small limit on the catalog.backend/src/schema.graphqlanddocs/API.md: the schema is the same (Int!). The text says that the count stops at 1001 and that a value above 1000 means "more than 1000". The paragraph that said that a cap "needs a change in the schema" now says that it is done, and that it only needs a new meaning of a value above 1000.docs/AI_USAGE.md.Testing
npx vitest run: 37 files, 350 tests passed. New: 5 insearch.test.ts(the catalog is smaller than the limit and is counted as it is, the count stops at one more than the most, it is not capped when the most is as big as the number of matches, a search is capped too, text with no searchable words counts 0).taketo check the tests: two of them fail without it.eslintandtsc -bpass.Open points
totalCount(the exact number) shows 1001 for a search with more than 1000 matches. The only client is the Elements page, which is changed in feat: make Load more elements fetch the next page #120.🤖 Generated with Claude Code