Repository navigation
fix(aggregate): filter before pagination, clamp limit, and return hasMore (closes #888) - #918
Open
mopxam-art wants to merge 1 commit into
Open
mopxam-art wants to merge 1 commit into
mopxam-art wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Overview
Closes #888 by ensuring the portfolio aggregate endpoint (
/v1/projects/aggregate) applies filters across the full dataset prior to pagination, enforces positive limit boundaries clamped to 1–100, and returnshasMoreand conditionalcursorfields matching the standard pagination contract.Problem & Motivation
Previously,
/v1/projects/aggregatesliced project IDs first viaArray.from({ length: limit }, (_, i) => cursor + i + 1)and then applied category/region filters to that slice. As a result, filtered responses returned fewer items than requestedlimit(or even 0 items) despite matching records existing in later offsets. Furthermore,limit <= 0was not rejected, and the response always echoedcursor: cursor + limitwithout indicating if more matching items existed.Changes
src/routes/aggregate.ts:limit(<= 0) and negativecursor(< 0) with400 Bad Request.limitto 100.getTotalProjects(), filtered the entire candidate pool acrosscategoryandregion, and then applied pagination slice[cursor, cursor + limit].total,filtered_total,limit,hasMore, and only returnscursorwhenhasMoreis true, aligning with/v1/projects.src/__tests__/aggregatePagination.test.ts:Verification
npx jest src/__tests__/aggregatePagination.test.ts --forceExit).npx tsc --noEmit).npx eslint src/routes/aggregate.ts).npm run build).