Skip to content

Fix dashboard date ranges with dynamic D1 queries - #52

Merged
newbish merged 2 commits into
mainfrom
fix/dynamic-dashboard-date-range
Aug 19, 2026
Merged

newbish merged 2 commits into
mainfrom
fix/dynamic-dashboard-date-range

Conversation

@tevnull

@tevnull tevnull commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • make the dashboard route loader depend on the selected timeframe URL parameters
  • query D1 with an indexed start/end range instead of loading a fixed history window
  • keep the default dashboard view at 30 days while allowing custom ranges longer than 90 days
  • keep OPENAI_USAGE_DAYS_BACK scoped to optional OpenAI synchronization
  • validate calendar dates before they reach server-side date arithmetic
  • preserve custom dates in URL state and remove snapshot-derived input bounds that blocked older ranges

Behavior

  • 24h, 7d, 30d, and 90d request their matching source windows
  • preset=custom&startDay=YYYY-MM-DD&endDay=YYYY-MM-DD requests that exact inclusive date range
  • timeframe navigation reruns the TanStack route loader and server function
  • publisher and ingestion behavior are unchanged

Verification

  • npm test — 31/31 passed
  • npm run typecheck — passed
  • npm run lint — passed
  • npm run build — passed
  • npx wrangler deploy --dry-run — passed
  • git diff --check origin/main — passed
  • SQLite EXPLAIN QUERY PLAN confirms the bounded read uses daily_usage_rollups_workspace_day_idx

Notes

Repository-wide Prettier checks have existing baseline drift in the touched TypeScript files; this change does not perform a drive-by full-file reformat.

@github-actions

Copy link
Copy Markdown

🚀 Cloudflare preview: https://token-usage-analytics-pr-52.tevpro.workers.dev

@newbish
newbish merged commit 6037660 into main Aug 19, 2026
4 checks passed
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