feat: add session time metrics (active time tracking per contribution)#528
Open
leecoder wants to merge 1 commit into
Open
feat: add session time metrics (active time tracking per contribution)#528leecoder wants to merge 1 commit into
leecoder wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
9 issues found across 24 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/frontend/src/lib/format.ts">
<violation number="1" location="packages/frontend/src/lib/format.ts:48">
P3: `formatDuration`'s example documentation does not match its actual output for sub-second durations.</violation>
</file>
<file name="packages/frontend/__tests__/api/leaderboard.test.ts">
<violation number="1" location="packages/frontend/__tests__/api/leaderboard.test.ts:68">
P1: Test expects two extra positional args for `getLeaderboardData`, so the assertion will never match the real 5-arg call.</violation>
</file>
<file name="packages/frontend/src/lib/db/migrations/0006_add_time_metrics_to_submissions.sql">
<violation number="1" location="packages/frontend/src/lib/db/migrations/0006_add_time_metrics_to_submissions.sql:1">
P1: Migration omits the `daily_breakdown.active_time_ms` column required by the updated submit path, causing runtime SQL failures.</violation>
</file>
<file name="packages/frontend/src/lib/db/schema.ts">
<violation number="1" location="packages/frontend/src/lib/db/schema.ts:184">
P1: daily_breakdown is missing the active_time_ms column even though submit/leaderboard code reads and writes it, creating schema drift and risking loss of per-day active-time data.</violation>
</file>
<file name="packages/frontend/src/components/GraphContainer.tsx">
<violation number="1" location="packages/frontend/src/components/GraphContainer.tsx:184">
P2: StatsPanel mixes filtered contribution stats with unfiltered active-time/session totals, so client filtering can make the numbers inconsistent.</violation>
</file>
<file name="packages/frontend/src/app/(main)/leaderboard/LeaderboardClient.tsx">
<violation number="1" location="packages/frontend/src/app/(main)/leaderboard/LeaderboardClient.tsx:1232">
P2: The new Time sort option is not supported by the user-rank API, so the current-user rank request silently falls back to tokens and shows inconsistent results.</violation>
</file>
<file name="crates/tokscale-core/src/lib.rs">
<violation number="1" location="crates/tokscale-core/src/lib.rs:1594">
P2: Time-metrics report loads and applies pricing even though the output does not use cost data, adding avoidable latency/work (and possible network/cache fetch) for no benefit.</violation>
</file>
<file name="crates/tokscale-core/src/sessionize.rs">
<violation number="1" location="crates/tokscale-core/src/sessionize.rs:127">
P1: `longest_continuous_ms` is calculated as the max single-session active duration and the `idle_gap_ms` parameter is ignored, so the metric does not match the documented merged-window semantics.</violation>
<violation number="2" location="crates/tokscale-core/src/sessionize.rs:182">
P2: `compute_max_concurrent` undercounts zero-duration sessions; single-message sessions can report 0 concurrent sessions even though the code intends them to count as 1.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
671a27e to
d015222
Compare
Contributor
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/tokscale-core/src/sessionize.rs">
<violation number="1" location="crates/tokscale-core/src/sessionize.rs:149">
P2: `longest_continuous_ms` is computed from wall-clock session spans, so long idle gaps inside a session are counted as continuous time and inflate the metric.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/tokscale-core/src/sessionize.rs">
<violation number="1" location="crates/tokscale-core/src/sessionize.rs:151">
P2: Collapsing each session to `start_ts + active_duration_ms` loses intra-session timing and can miscompute the longest continuous activity window.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
1b6f11f to
b9a2eda
Compare
b9a2eda to
4ac6a96
Compare
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
Add active time tracking per contribution, enabling users to see how much time they actually spent coding.
Changes
CLI (Rust)
time-metricssubcommand showing active time, longest session, and concurrency statsactiveTimeMsin graph/submit payloadsFrontend
active_time_mscolumn todaily_breakdowntable (migration 0006)Testing
Summary by cubic
Adds end-to-end session time metrics so users can see active coding time, longest continuous session, and peak concurrency. Leaderboards and profiles now surface time (including sort by time), and the CLI adds a
time-metricsreport.New Features
crates/tokscale-core): Addedsessionizewith a 3‑min idle gap; computes per‑dayactiveTimeMsand globaltimeMetrics(total active, wall, longest continuous with idle‑gap merge, max concurrency incl. zero‑duration, session count); graph payloads includeactiveTimeMsandtimeMetrics; addedget_time_metrics_report.crates/tokscale-cli): Newtime-metricssubcommand with date/client filters,--json, and--no-spinner; prints total active, wall‑clock, longest continuous, max concurrency, sessions, and processing time; graph JSON includestimeMetricsand per‑dayactiveTimeMs; skips pricing init for faster runs.packages/frontend): Submit API acceptstimeMetrics; persists submission metrics (total_active_time_ms,longest_continuous_ms,max_concurrent_sessions,session_count) and dailyactive_time_ms; leaderboard APIs and user rank supportsortBy=time; leaderboard adds a “Time” column and period totals; profile and graph stats show “Active Time” and “Sessions” (hidden when a client filter is active); addedformatDuration; submission validation updated to allowtimeMetricsand per‑dayactiveTimeMs.Migration
0007_add_time_metrics_to_submissions.sql.Written for commit 4ac6a96. Summary will update on new commits.