Skip to content

perf(admin): devpass usage reads from aggregator tables - #2328

Merged
smakosh merged 1 commit into
mainfrom
claude/fetch-aggregators-tables-X1f0J
May 19, 2026
Merged

smakosh merged 1 commit into
mainfrom
claude/fetch-aggregators-tables-X1f0J

Conversation

@smakosh

@smakosh smakosh commented May 19, 2026 •

Copy link
Copy Markdown
Member

Top models/providers panels now sum projectHourlyModelStats joined
to project -> organization with the DevPass filter, replacing the
expensive scan over the raw log table. Top coding agents reads from
globalSourceStats (cross-org), matching the global-stats endpoint
since no per-org source aggregator exists.

Summary by CodeRabbit

  • Improvements
    • Refined DevPass usage reporting to correctly reflect organizations with active or past DevPass plans
    • Updated metric descriptions for model spend, provider usage, and coding agent data to improve clarity

Review Change Stack

Top models/providers panels now sum projectHourlyModelStats joined
to project -> organization with the DevPass filter, replacing the
expensive scan over the raw log table. Top coding agents reads from
globalSourceStats (cross-org), matching the global-stats endpoint
since no per-org source aggregator exists.
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eab4f5a6-b99d-4f55-9868-c1d2ef887ebf

📥 Commits

Reviewing files that changed from the base of the PR and between 6a9a7de and 54ad2aa.

📒 Files selected for processing (2)
  • apps/api/src/routes/admin.ts
  • ee/admin/src/components/devpass-usage.tsx

Walkthrough

The DevPass usage reporting endpoint is refactored to use pre-computed rollup tables instead of raw logs. Model and provider totals now come from projectHourlyModelStats, source totals from globalSourceStats with UTC day-boundary alignment, and UI descriptions are updated to document the new aggregation source.

Changes

DevPass Usage Rollup Migration

Layer / File(s) Summary
Filter documentation and aggregation context
apps/api/src/routes/admin.ts
The inline comment documenting DevPass organization filtering is updated to reflect the new rollup-based aggregation strategy.
Model and provider aggregation from projectHourlyModelStats
apps/api/src/routes/admin.ts
modelRows and providerRows queries are rewritten to aggregate from projectHourlyModelStats (joined through project and organization) instead of raw tables.log, with shared DevPass and time-window filtering.
Source aggregation with UTC boundary snapping
apps/api/src/routes/admin.ts
sources aggregation switches to globalSourceStats with sourceStart/sourceEnd snapped to UTC day boundaries to match the rollup bucket grain, grouped by source and ranked by cost.
UI description updates for rollup-based reporting
ee/admin/src/components/devpass-usage.tsx
The DevpassUsage component descriptions are updated to indicate that model totals come from hourly project rollups, and source totals are from global cross-org source rollups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • theopenco/llmgateway#2085: Introduces /admin/devpass endpoints that also derive DevPass subscriber billing KPIs from hourly and project rollups—directly connected at the DevPass stats aggregation layer.
  • theopenco/llmgateway#2279: Modifies apps/api/src/routes/admin.ts for DevPass-related filtering and aggregation scope changes in /metrics and subscriber listing endpoints.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'perf(admin): devpass usage reads from aggregator tables' directly and accurately describes the main change: replacing expensive raw log table scans with aggregator table reads.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fetch-aggregators-tables-X1f0J

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@smakosh
smakosh added this pull request to the merge queue May 19, 2026
Merged via the queue into main with commit 1c330df May 19, 2026
12 checks passed
@smakosh
smakosh deleted the claude/fetch-aggregators-tables-X1f0J branch May 19, 2026 09:04
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.

2 participants