Repository navigation
feat(coderd/database): add AI spend session count query - #29222
Closed
ibetitsmike wants to merge 3 commits into
Closed
ibetitsmike wants to merge 3 commits into
ibetitsmike wants to merge 3 commits into
Conversation
ibetitsmike
force-pushed
the
mike/ai-spend-query-session-counts
branch
from
September 11, 2026 10:01
b7aaecd to
fb1a07e
Compare
ibetitsmike
force-pushed
the
mike/ai-spend-query-rollups
branch
from
September 11, 2026 10:01
d3535c6 to
a58258c
Compare
ibetitsmike
marked this pull request as ready for review
September 11, 2026 11:31
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. |
ibetitsmike
force-pushed
the
mike/ai-spend-query-rollups
branch
from
September 14, 2026 08:03
a58258c to
65a933d
Compare
ibetitsmike
force-pushed
the
mike/ai-spend-query-session-counts
branch
from
September 14, 2026 08:03
fb1a07e to
11e7250
Compare
ibetitsmike
marked this pull request as draft
September 15, 2026 18:48
ibetitsmike
force-pushed
the
mike/ai-spend-query-rollups
branch
from
September 15, 2026 18:51
65a933d to
4e98501
Compare
Collaborator
Author
|
Closing without a counterpart. The stack was reworked onto the released organization spend export (
|
This was referenced Sep 15, 2026
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.
Third of a seven-PR stack that restores the admin Spend page removed in #27330, rebuilt on the cost data AI Gateway already records. The stack lands the three database queries first (per-user spend, rollups, session counts), then the codersdk types, the users endpoint, the summary endpoints, and finally the page itself (#28964). Together the six backend PRs produce exactly the tree previously reviewed as a single PR; they were split so each layer can be read on its own.
Adds
ListAIBridgeSpendSessionCounts, which counts distinct(initiator_id, session_id)pairs per client plus one deduplicated total. Summing the per-client counts would overcount because a session can issue requests through several clients.It is a separate query rather than another grouping set because
COUNT(DISTINCT ...)disables hash aggregation on Postgres 13; the dedupe happens in aGROUP BYCTE so the outer count stays in memory. Includes the dbauthz, dbmetrics, and dbmock wiring and querier coverage for the per-client and total counts.