Skip to content

fix: count unpriced AI model usage by when it was recorded - #31751

Merged
ssncferreira merged 1 commit into
mainfrom
ssncf/unpriced-models-query
Nov 13, 2026
Merged

ssncferreira merged 1 commit into
mainfrom
ssncf/unpriced-models-query

Conversation

@ssncferreira

@ssncferreira ssncferreira commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Updates the unpriced AI models query behind the weekly owner notification to count token usage by when it was recorded (token_usages.created_at) in a [period_start, period_end) window, consistent with the other AI spend queries. It also returns one row per provider name and model instead of per provider type, so the unpriced models endpoint later in this stack can reuse it. The notification payload keeps the same format.

Changes

  • Rename GetUnpricedAIModelsSince to GetUnpricedAIModels. It used interceptions.started_at with no end.
  • Treat usage as unpriced only when no price was found (cost_micros IS NULL AND priced_model IS NULL), so usage whose price was found but whose cost could not be computed is not reported.
  • Return one row per live provider name and model, with the provider's display name, icon and type.
  • The notification passes the last 7 days and merges rows by provider type, since site-wide prices are keyed by type, so its payload keeps the same shape.
  • Table-driven query tests and a notification test for providers sharing a type.

Related to AIGOV-730

Note

Generated by Coder Agents on behalf of @ssncferreira.

@ssncferreira
ssncferreira added this pull request to stack #31754 November 4, 2026 12:36
@ssncferreira ssncferreira changed the title ssncf/unpriced models query refactor: list unpriced AI models per provider over a period Nov 4, 2026
@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch from 9135e59 to 377dbe2 Compare November 4, 2026 12:43
@ssncferreira ssncferreira changed the title refactor: list unpriced AI models per provider over a period fix: count unpriced AI model usage by when it was recorded Nov 4, 2026
@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

AIGOV-730

@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch 12 times, most recently from e95f0f0 to b5ea285 Compare November 6, 2026 15:46
@ssncferreira
ssncferreira marked this pull request as ready for review November 6, 2026 16:48
@ssncferreira
ssncferreira temporarily deployed to main November 9, 2026 10:05 — with GitHub Actions Inactive
@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch from b5ea285 to cb33a9e Compare November 11, 2026 12:53
@ssncferreira
ssncferreira temporarily deployed to main November 11, 2026 12:53 — with GitHub Actions Inactive
@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch from cb33a9e to f0275a1 Compare November 12, 2026 10:20
@ssncferreira
ssncferreira temporarily deployed to main November 12, 2026 10:20 — with GitHub Actions Inactive
@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch from f0275a1 to ddd804f Compare November 13, 2026 10:58
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 10:58 — with GitHub Actions Inactive
@ssncferreira
ssncferreira requested a review from pawbana November 13, 2026 11:58
@ssncferreira
ssncferreira force-pushed the ssncf/unpriced-models-query branch from ddd804f to 610a969 Compare November 13, 2026 12:17
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 12:17 — with GitHub Actions Inactive
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 12:21 — with GitHub Actions Inactive
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 12:24 — with GitHub Actions Inactive
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 12:24 — with GitHub Actions Inactive
@ssncferreira
ssncferreira merged commit 8c5921d into main Nov 13, 2026
41 checks passed
@ssncferreira
ssncferreira deleted the ssncf/unpriced-models-query branch November 13, 2026 13:21
@ssncferreira
ssncferreira temporarily deployed to main November 13, 2026 13:21 — with GitHub Actions Inactive
@ssncferreira
ssncferreira temporarily deployed to docs-preview November 13, 2026 13:21 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026

This branch was previously deployed

2 inactive deployments
main — 610a9690 Deployed Nov 13, 2026 by ssncferreira via cla #256488
docs-preview — 610a9690 Deployed Nov 13, 2026 by ssncferreira via cleanup #34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants