fix(submit): aggregate device time totals - #627
Merged
junhoyeo merged 1 commit intoMay 30, 2026
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Validation * Validation tier: Tier 2 - Narrow Runtime Change, localized /api/submit aggregation behavior. * TDD red: bun run --cwd packages/frontend test -- __tests__/api/submitAuth.test.ts -t "active time": FAIL before fix, 3 failed assertions showed latest-payload active time or missing totalActiveTimeMs instead of persisted daily-row aggregate. * bun install: PASS, installed workspace dependencies after the first test run could not resolve frontend packages. * bun run --cwd packages/frontend test -- __tests__/api/submitAuth.test.ts -t "active time": PASS, 3 passed / 8 skipped. * bun run --cwd packages/frontend test -- __tests__/api/submitAuth.test.ts __tests__/api/submit.test.ts: PASS, 60 passed. * bun run --cwd packages/frontend lint -- src/app/api/submit/route.ts __tests__/api/submitAuth.test.ts: PASS. * git diff --check: PASS. * git diff --cached --check: PASS. * Ledger: not applicable - not required for selected validation tier/change family. * Version: not applicable - no package or release manifest version sync is required for this localized frontend route fix. * Not run: full frontend build/full test suite - not required for selected Tier 2 validation; targeted submit route tests and lint cover the changed behavior. Rollback * git revert HEAD
junhoyeo
force-pushed
the
codex/submit-device-time-metrics-20260528
branch
from
May 30, 2026 13:30
fdd4e0f to
7d06744
Compare
This was referenced Jul 6, 2026
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.
Summary
submissions.totalActiveTimeMsfrom persisteddaily_breakdown.active_time_msrows across all submitted devices.longestContinuousMs,maxConcurrentSessions,sessionCount) tied to incomingtimeMetricsbecause they cannot be safely recomputed from daily active-time buckets.timeMetrics.Why
The submit path already recalculates token and cost totals from all persisted daily rows, but
totalActiveTimeMswas still copied from the latest incoming payload. With multiple devices, all-time profile and leaderboard time totals could represent only the latest submitting device instead of the user's aggregate submitted history. This PR makes active-time totals follow the same persisted-row aggregate model as token totals.Diff scope
packages/frontend/src/app/api/submit/route.tspackages/frontend/__tests__/api/submitAuth.test.tsBranch integrity
mainc21f0f533205ad63e9154666c294bb789d2415c9IvGolovach:codex/submit-device-time-metrics-20260528fdd4e0f191b434e47601e089d8d59d3d2fa00b70origin/main:1 ahead / 0 behindfdd4e0f191b434e47601e089d8d59d3d2fa00b70 fix(submit): aggregate device time totalsValidation
bun run --cwd packages/frontend test __tests__/api/submitAuth.test.ts __tests__/api/submit.test.ts: PASS, 60 tests passed.bun run --cwd packages/frontend lint -- src/app/api/submit/route.ts __tests__/api/submitAuth.test.ts: PASS, no output.git diff --check origin/main...HEAD: PASS, no output.git status --short --untracked-files=all: PASS, clean worktree.Runtime safety
active_time_ms.Migration notes
Not applicable - no database migration or schema change.
Rollback plan
Rollback: revert this PR. DB downgrade: not applicable. Data repair: not applicable. Operational caveats: reverting restores latest-payload
totalActiveTimeMsbehavior.Known residual risks
longestContinuousMs,maxConcurrentSessions, andsessionCountremain sourced from incomingtimeMetricswhen present because daily active-time buckets do not contain enough information to recompute those session-shape metrics correctly.Summary by cubic
Aggregates all-time active time from persisted daily device rows in the
api/submitroute so multi-device totals are correct. Preserves same-device replacement and keeps session metrics from incomingtimeMetrics.submissions.totalActiveTimeMsfrom SUM ofdaily_breakdown.active_time_msacross all submitted devices.longestContinuousMs,maxConcurrentSessions,sessionCount) use incomingtimeMetricswhen provided.Written for commit 7d06744. Summary will update on new commits.