Repository navigation
fix(cursor): page user spend by the top-level totalPages - #9381
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
CollectUserSpend used nextPostPage, which stops unless the response has pagination.hasNextPage. POST /teams/spend has no pagination object; it reports totalMembers and a top-level totalPages. So the collector always stopped after the first page, and teams with more than 100 members lost the spend of everyone past the first page. Add nextSpendPage, which reads totalPages and stops when the current page reaches it, and use it for the spend collector. Usage events and daily usage keep nextPostPage. Closes apache#9379 Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
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.
Summary
CollectUserSpendpagedPOST /teams/spendwithnextPostPage. That function was written forfiltered-usage-eventsand stops unless the response haspagination.hasNextPage: true. The spend endpoint has nopaginationobject. Per the Admin API docs ("Get Spending Data"), it returnsteamMemberSpend,subscriptionCycleStart,totalMembersand a top-leveltotalPages. BecausehasNextPagealways decoded asfalse, the collector stopped after page 1. WithpageSize100, teams with more than 100 members lost the spend of every member past the first page.Changes:
tasks/user_spend_collector.go: newnextSpendPagereads the top-leveltotalPages. It requests the next page until the current page reachestotalPages, and stops right away whentotalPagesis 0 (no members).CollectUserSpendnow uses it.nextPostPageis unchanged for usage events and daily usage, which do returnpagination.hasNextPage.tasks/user_spend_collector_test.go: tests that pages continue from 1 to 2 to 3 whentotalPagesis 3 and stop on the last page. Also covers single-page and empty responses.Does this close any open issues?
Closes #9379
Screenshots
N/A
Other Information
go test ./plugins/cursor/...: pass.gofmtandgolangci-lint run ./plugins/cursor/...: clean.pr-type/bug-fix.Generated-by:trailer per the ASF generative tooling guidance.🤖 Generated with Claude Code