Skip to content

fix(cms): aggregate report costs in Postgres - #93

Merged
snowopsdev merged 1 commit into
mainfrom
codex/qa-20260905-lane11
Sep 5, 2026
Merged

snowopsdev merged 1 commit into
mainfrom
codex/qa-20260905-lane11

Conversation

@snowopsdev

Copy link
Copy Markdown
Owner

What Problem This Solves

The Reports admin page hydrated every matching cost log in sequential 1,000-row batches. With 10,067 cost rows, all-time and month navigation repeatedly exceeded the existing five-second browser contract.

Why This Change Was Made

Cost totals are aggregate data, so the database can compute them without transferring every log document through Payload. This change uses one parameterized PostgreSQL grouped query after evaluating the collection read policy. It accepts only typed date and run filters and fails closed if the read policy becomes row-scoped.

User Impact

Reports remain accurate while loading far faster as cost history grows. In the isolated browser fixture, the median all-time navigation fell from 5,772 ms to 419 ms and month navigation fell from 5,867 ms to 820 ms. Null stages and models still appear in the existing unknown bucket.

Evidence

  • Fail-before regression observed seven cost-log collection reads.
  • Focused CMS integration tests: 5/5 passed, including 5,026-row aggregation, null buckets, inclusive date boundaries, and a quoted run identifier.
  • Full CMS integration suite: 402/402 passed across 41 files.
  • Full Chromium suite: 16/16 passed.
  • CMS typecheck, scoped lint, and diff checks passed.
  • Browser benchmark used 10,067 rows before the fix and 15,098 rows after it.

@snowopsdev
snowopsdev marked this pull request as ready for review September 5, 2026 03:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-05T03:57:04.656544Z f187aab Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f187aab3aa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread cms/src/lib/reportQueries.ts Resolved
@snowopsdev
snowopsdev merged commit 27d6923 into main Sep 5, 2026
7 checks passed
@snowopsdev
snowopsdev deleted the codex/qa-20260905-lane11 branch September 5, 2026 05:36
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