Skip to content

feat: add organization AI spend overview queries - #31711

Draft
ssncferreira wants to merge 1 commit into
mainfrom
ssncf/ai-spend-overview-queries
Draft

ssncferreira wants to merge 1 commit into
mainfrom
ssncf/ai-spend-overview-queries

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the database queries behind the organization AI spend overview endpoint (#31709). They read the daily spend aggregate (ai_user_daily_spend), scoped to the organization through each spend row's effective group, over a [period_start, period_end) range of UTC days.

Changes

  • GetOrganizationAISpendTotals: the number of users with spend, the total spend, and the median spend per user.
  • ListOrganizationAISpendPerUser: one page of users, most spend first, with one row for each group their spend was attributed to. Pages count users, not groups.
  • GetOrganizationAISpendPerDay: the spend for every UTC day in the range, including days without spend.
  • dbauthz checks matching /ai/spend/users (read on organization group members).
  • Querier and dbauthz tests.

Part of AIGOV-728

Note

Generated by Coder Agents on behalf of @ssncferreira.

@ssncferreira
ssncferreira added this pull request to stack #31712 November 3, 2026 20:04
@ssncferreira ssncferreira changed the title ssncf/ai spend overview queries feat(coderd/database): add organization AI spend overview queries Nov 3, 2026
@ssncferreira
ssncferreira force-pushed the ssncf/ai-spend-overview-queries branch from b32e812 to fa956d9 Compare November 3, 2026 20:10
@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

AIGOV-728

@ssncferreira ssncferreira changed the title feat(coderd/database): add organization AI spend overview queries feat: add organization AI spend overview queries Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant