Skip to content

[codex] Add profile range filters - #785

Merged
junhoyeo merged 2 commits into
junhoyeo:mainfrom
Zhan-boyi:codex/profile-range-filters
Jun 29, 2026
Merged

[codex] Add profile range filters#785
junhoyeo merged 2 commits into
junhoyeo:mainfrom
Zhan-boyi:codex/profile-range-filters

Conversation

@Zhan-boyi

@Zhan-boyi Zhan-boyi commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds overview range filters to public user profiles so /u/[username] can switch between all-time, rolling 7-day, and rolling 30-day views.

What changed

  • Added period=week|month support to GET /api/users/[username].
  • Recalculates profile overview totals from daily_breakdown rows for rolling ranges, including tokens, cost, token breakdown, active days, active time, clients, and model usage.
  • Preserves canonical username redirects while keeping the selected period.
  • Adds an All / 7d / 30d segmented control on public profile pages.
  • Hides all-time rank on rolling ranges to avoid mixing all-time rank with period-scoped stats.
  • Adds an API regression test for rolling period overview aggregation.

Notes

month is treated as a rolling 30-day window on user profiles, matching the UI label 30d. This leaves the existing leaderboard period semantics untouched.

Validation

Passed:

npx --yes bun@latest run test -- __tests__/api/usersProfile.test.ts
node_modules/.bin/eslint src/app/api/users/'[username]'/route.ts src/app/u/'[username]'/page.tsx src/app/u/'[username]'/ProfilePageClient.tsx __tests__/api/usersProfile.test.ts

Observed existing unrelated blockers when running broader checks:

npx --yes bun@latest run test

fails in __tests__/lib/clientRegistry.test.ts because zcode and opencodereview are rejected/missing from the frontend registry.

npx --yes bun@latest run lint

fails on pre-existing react-hooks/set-state-in-effect issues in ViewSelector/Footer related files outside this change.

node_modules/.bin/tsc --noEmit --project tsconfig.json

is blocked in this sparse checkout by an existing tuple typing issue in groupMemberRoleRoute.test.ts and by omitted public asset files such as public/assets/hero-bg.png.


Summary by cubic

Adds range filters to public profiles (All, 7d, 30d) with rolling stats and a segmented control. Updates the API to support period-scoped data and preserves the selected period across redirects.

  • New Features
    • API: GET /api/users/[username] accepts period=week|month (default all), returns period and dateRange, recalculates rolling totals from daily_breakdown (tokens, cost, token breakdown, active days/time), derives clients/models from the period, hides rank and sets sessionCount=0 for rolling windows; canonical username redirects keep period. Note: month is a rolling 30-day window.
    • UI: Adds All / 7d / 30d segmented control on /u/[username]; uses query params to fetch the selected period and preserves it in server/client redirects.
    • Tests: Adds an API regression test covering rolling period aggregation and date range boundaries.

Written for commit d746a2f. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
tokscale Ready Ready Preview, Comment Jun 29, 2026 10:56am

Request Review

@Zhan-boyi
Zhan-boyi marked this pull request as ready for review June 28, 2026 15:21

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@junhoyeo junhoyeo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Zhan-boyi — clean, well-scoped addition. The period filtering (all/week/month) is solid: UTC-normalized date ranges (week = 7 days inclusive, month = 30), the canonical-username redirect preserves the period param, and rolling-period overview stats are correctly recomputed from the daily-breakdown rows. The test coverage is thorough — date-range assertions, recomputed totals, and clients/models. cubic clean, CI green.

(Minor, non-blocking: sessionCount reads 0 for rolling periods since it isn't derivable from daily rows — fine to follow up later if you want to surface it.) 🚀

@junhoyeo
junhoyeo merged commit 7efcf1a into junhoyeo:main Jun 29, 2026
7 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