Repository navigation
UN-4515 [FIX] Dashboard Overview: repair window, local-day date range, Prompt Studio-only orgs - #2387
Merged
Merged
Conversation
…ange - backfill_metrics: add --start-date/--end-date (UTC days, end inclusive) so the daily rows damaged between 12 Mar and 8 Apr 2026 can be rewritten. --days only reaches back from now. The range stops just before the next midnight because the source queries are end-inclusive. - Metrics dashboard: send the overview range with its UTC offset (format()) instead of toISOString(). The backend takes .date() on it, so users ahead of UTC were querying one day earlier than they picked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_active_org_ids shortlisted orgs by WorkflowExecution only. Prompt Studio records page_usage without a workflow execution, so orgs using only Prompt Studio never got daily rows. Union in orgs with page_usage in the lookback, served by idx_page_usage_created_org. test_tasks.py also carries a ruff-format pass: the file was unformatted on main since #2276 and the pre-commit hook formats the whole file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
[Medium impact] The PR appears safe to merge; no blocking issues were found.
|
athul-rs
requested review from
hari-kuriakose,
jaseemjaskp,
tahierhussain and
wicky-zipstack
October 27, 2026 09:21
…e monthly totals A --start-date/--end-date range covering part of a month summed only those days into the monthly row and replaced the stored total. A month outside the aggregation task's current-and-previous window is never rederived, so it stayed undercounted. Such a range now needs --skip-monthly; whole-month ranges still rebuild the monthly row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jaseemjaskp
approved these changes
Oct 27, 2026
Contributor
Frontend Lint Report (Biome)✅ All checks passed! No linting or formatting issues found. |
|
Contributor
Unstract test resultsPer-group results
Critical paths
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
backfill_metricstakes--start-date/--end-date(UTC days, end inclusive), so a past window can be repaired.--daysonly counts back from now.format()) instead oftoISOString()._active_org_ids) now includes orgs withpage_usagein the lookback, as well as orgs with workflow executions.Why
Three defects make the Overview page disagree with actual page usage:
now - 7dwithout truncating to midnight. Each run rewrote the oldest day with only the pages from that time of day onward. UN-3322 [FIX] Optimize dashboard metrics aggregation task #1837 fixed the window but the damaged days were never rebuilt. On US prod, 78 orgs are missing 1,355,497 pages in that window. The monthly tier is correct.toISOString()converts the picked local midnight to UTC, and the overview endpoint takes.date()on it. A UTC+8 user picking 1 to 30 Apr queries 31 Mar to 29 Apr.page_usagewithout a workflow execution, so these orgs were never shortlisted and have no daily rows. On US prod: 149 orgs, 8,465 pages, 212 org-days since 9 Apr. Every daily row that does exist since 9 Apr matches live usage exactly.How
_resolve_windowbuilds the start/end instants. With--end-date, the end stops 1 µs before the next midnight: the source queries usecreated_at__lte, so ending on midnight would rewrite the following day with only its 00:00 rows.--start-daterange that covers only part of a month needs--skip-monthly. Otherwise the monthly row would be replaced with only those days, and months outside the task's current-and-previous window are never rederived. Whole-month ranges still rebuild the monthly row./metrics/overview/parses dates withdatetime.fromisoformat, which keeps the offset, so.date()yields the user's calendar day. The Usage by Deployment tab still sendstoISOString(). It compares instants, which is already correct._active_org_idsunions orgs fromPageUsage(stringorganization_id, mapped to the PK). The lookup is served byidx_page_usage_created_org (created_at, organization_id).Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
backfill_metricsbehaves as before unless--start-dateis passed.Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
test_tasks.pywas left unformatted under ruff 0.3.4; the pre-commit hook reformats the whole file, which accounts for most of that file's diff)Dependencies Versions
Notes on Testing
--end-datewithout--start-dateis refused--skip-monthlyis refused and keeps the stored monthly total; a whole-month range rebuilds itpage_usageis shortlistedpage_usageunion fails the shortlist test, and disabling the month-end check fails the partial-last-month case.dashboard_metricssuite: 237 passed. Frontend build passes.2026-04-29T16:00:00.000Zresolves to 29 Apr; the new value2026-04-30T00:00:00+08:00resolves to 30 Apr.Post-release repair (one-time, per environment, dry-run first):
This rebuilds the 2026 daily tier for all orgs. It covers the damaged window, the Prompt Studio-only days and the days before the dashboard's history began. Rows that are already correct are rewritten with the same values.
Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code