fix(cost): retain daily rollups for 180 days#301
Conversation
|
All contributors on this pull request have signed the CLA. |
|
I have read the CLA Document and I hereby sign the CLA |
Yevanchen
left a comment
There was a problem hiding this comment.
Verified against the actual query semantics: getOrganizationBillingCostCard computes the previous LAST_90_DAYS window as resolveCostWindow(range, new Date(window.sinceMs - 1)), whose oldest needed rollup date is today-179, while the old cleanup predicate retained only ~97 days -- so previousTotals was silently truncated once the system ran long enough. The 180-day cutoff covers the previous window with a one-day margin, and the pre-streamline PRD explicitly documented the 180-day retention contract. The test pins the exact boundary (cutoff 2026-01-14, boundary row 2026-01-15 retained) through the real production predicate and real queryTotals path. LGTM.
Summary
Why
The prior cleanup used a 90-day window relative to an already seven-day-old detail cutoff, retaining roughly 97 days. That deletes data required by the cost dashboard previous-period comparison and can make historical totals incomplete.
Verification
just test-file apps/api/tests/cost-rollup.test.ts(1 passing);just check(939 passing tests, plus format, docs, lint, type, and GraphQL checks).LAST_90_DAYScomparison path.Impact
Review