Skip to content
This repository was archived by the owner on Nov 30, 2026. It is now read-only.

fix: fall back to ingested cost for Total Cost delta when effective is zero - #492

Merged
siropkin merged 1 commit into
mainfrom
fix/476-total-cost-delta-fallback
May 25, 2026
Merged

siropkin merged 1 commit into
mainfrom
fix/476-total-cost-delta-fallback

Conversation

@siropkin

Copy link
Copy Markdown
Owner

Summary

  • When the price-list backfill hasn't reached previous-period rollup rows, cost_cents_effective sums to 0 while total_messages / total_sessions are non-zero — the Total Cost card shows a bare — while Messages and Sessions show real percentage deltas on the same row.
  • Falls back to totalCostCentsIngested (already returned by the dashboard_overview_stats RPC) for both current and previous period when the previous window's effective cost is zero but ingested cost is non-zero, so the delta still answers "is spend up or down?"
  • Appends (list price) to the delta caption when the ingested fallback is active, so the viewer knows the comparison uses list prices rather than effective/team pricing.
  • No regression for genuine zero-activity previous windows — those still render — as designed.

Closes #476

Test plan

  • On /dashboard (default ?days=7), verify Total Cost delta shows a real percentage when Messages/Sessions do
  • On /dashboard?days=30, same check
  • When the fallback is active, verify the caption reads e.g. "vs previous 7d (list price)"
  • When both effective and ingested previous cost are 0 (genuine zero-activity), verify — still renders
  • TypeScript type-check passes (tsc --noEmit)

🤖 Generated with Claude Code

…s zero

When the price-list backfill hasn't reached previous-period rows,
cost_cents_effective sums to zero while messages/sessions are non-zero,
causing the Total Cost card to show "—" while sibling cards show real
deltas. Fall back to the ingested cost lens for the delta comparison so
the card stays informative. Appends "(list price)" to the caption when
the fallback is active.

Closes #476

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercel Bot commented May 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
budi-cloud Ready Ready Preview, Comment May 25, 2026 3:59am

@siropkin
siropkin merged commit 484c8f6 into main May 25, 2026
8 checks passed
@siropkin
siropkin deleted the fix/476-total-cost-delta-fallback branch May 25, 2026 04:05

This branch was successfully deployed

1 active deployment
Preview — 392bf6f1 Deployed May 25, 2026 by vercel[bot]
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.

Overview: Total Cost delta collapses to "—" while Messages/Sessions show real deltas for the same previous window

1 participant