Skip to content

Chore/fix committed metrics backend#10951

Open
sebastianekstrom wants to merge 2 commits intomainfrom
chore/fix-committed-metrics-backend
Open

Chore/fix committed metrics backend#10951
sebastianekstrom wants to merge 2 commits intomainfrom
chore/fix-committed-metrics-backend

Conversation

@sebastianekstrom
Copy link
Copy Markdown
Contributor

Committed metrics were calculated relative to request time now, which made them sensitive to timezone and the current date. This means the same query could return different values depending on when and where it was requested from.

The fix is to calculate committed metrics relative to each bucket timestamp instead.

Example: For a single subscription at $500 that starts at T and is canceled at T+2, historical cMRR should be:

  • T: $500
  • T+1: $500
  • T+2: $0
  • T+3: $0

With timestamp, looking at the T+1 bucket always returns $500.

With now, if you open the dashboard at T+3 and look back at T+1, that old bucket can be recalculated using the current time instead of the bucket’s time, which can incorrectly make it drop to $0.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

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

Project Deployment Actions Updated (UTC)
polar Ready Ready Preview, Comment Apr 24, 2026 7:49am
polar-sandbox Ready Ready Preview, Comment Apr 24, 2026 7:49am

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

OpenAPI Changes

No changes detected in the OpenAPI schema.

@github-actions
Copy link
Copy Markdown
Contributor

🚀 Expo preview is ready!

  • Project → Polar
  • Platforms → android, ios
  • Scheme → polar
Android
(c5fd19666e179e2218fa86263a38c107cecc8e3b)
More info
iOS
(99e8ad9de62631576e62b6f22d96b94e5c97cae7)
More info

Learn more about 𝝠 Expo Github Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Preview Environment
URL: https://polar-preview-vm.taildbff7b.ts.net/pr-10951
API: https://polar-preview-vm.taildbff7b.ts.net/pr-10951/v1/
Logs: backend
SHA: 03cd11bf36f91ddbd9d93963d999c39d84e4c7a2

@Yopi
Copy link
Copy Markdown
Contributor

Yopi commented Apr 23, 2026

Sorry @sebastianekstrom , I made some other changes you need to rebase ontop of, but I think this makes sense!

_not_in_trial / _in_trial truncated both trial_end and the bucket
timestamp and compared those. `trial_end < t + interval` gives the
same answer without the date_trunc calls on either side.
@Yopi
Copy link
Copy Markdown
Contributor

Yopi commented Apr 24, 2026

@sebastianekstrom ok to go? 😄

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