Repository navigation
feat: filter the organization AI spend export query by provider, model, and client - #29220
ibetitsmike wants to merge 1 commit into
Conversation
2153280 to
aeb88bc
Compare
d3535c6 to
a58258c
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
a58258c to
65a933d
Compare
aeb88bc to
71dfc0c
Compare
71dfc0c to
7345ff5
Compare
65a933d to
4e98501
Compare
|
This PR was reworked in place on 2026-09-15: the stack now extends the released organization spend export ( @codex review
|
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…l, and client Add optional provider_name, model, and client parameters to ExportOrganizationAISpend, matching the predicates ListOrganizationAISpendUsers already applies. An empty value matches everything, and client compares against COALESCE(client, 'Unknown') like the AI Gateway sessions list. The export handler passes empty filters for now; exposing them as query parameters follows separately. Cover the filters on the export and add a reconciliation test that sums the export per user and compares it with the user report for every filter combination, so the two queries cannot drift apart silently.
7345ff5 to
ba04efe
Compare
4e98501 to
7bbb2c6
Compare
ssncferreira
left a comment
There was a problem hiding this comment.
Given that this PR stack is for the User spend page, and we agreed to use a different endpoint than the CSV export, I would suggest keeping this stack focused on the user spend page and moving this PR to the stack for the CSV page.
|
Closing: this stack was reshaped to drop the CSV export dimension filters. The Spend page reads the per-user JSON report (
|
Second of a six-PR stack that reworks the AI spend page onto the released organization spend export,
GET /api/v2/organizations/{organization}/ai/spend/export, and a sibling per-user endpoint,GET /api/v2/organizations/{organization}/ai/spend/users, instead of the deployment-wide/api/v2/ai-gateway/spend/*endpoints this stack previously proposed. Every PR in the stack was rewritten in place from current main; the head branch name predates the rework. The export's accounting rules are unchanged: token usage bycreated_atin[period_start, period_end), attributed to the organization through the effective budget group, so the page reconciles with the CSV and with daily budget accounting.Adds optional
provider_name,model, andclientfilters toExportOrganizationAISpend, with the same predicates asListOrganizationAISpendUsers.clientmatches afterCOALESCE(client, 'Unknown'), as the AI Gateway sessions listing does. Result columns are unchanged.The querier tests seed one fixture for both queries and assert that, for every filter combination, the CSV rows summed per user equal the JSON rows and the report total. Removing either query's client predicate fails those tests.
Touches
enterprise/coderd/aibridge.goonly to name the new parameter fields forexhaustruct; the handler wires them in #29224.