Skip to content

Fix filtered dashboard durations - #1685

Merged
skyfallwastaken merged 1 commit into
mainfrom
fix-filtered-dashboard-durations
Sep 6, 2026
Merged

skyfallwastaken merged 1 commit into
mainfrom
fix-filtered-dashboard-durations

Conversation

@skyfallwastaken

@skyfallwastaken skyfallwastaken commented Sep 6, 2026

Copy link
Copy Markdown
Member

Summary of the problem

Dashboard dimension filters were applied before duration attribution. Gaps between unrelated matching heartbeats could therefore add up to 120 seconds each and substantially inflate filtered coding time.

Describe your changes

Calculate capped current-row durations from the complete eligible timeline before applying language, project, editor, operating system or category filters. Use the same attribution for totals, grouped dimensions, weekly projects and coding rhythm, then version the cached result.

This is PR 2 of 3 in a stacked change. It depends on #1684 and is followed by #1686.

Screenshots / Media

Not applicable. This corrects calculated values without changing the interface.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects filtered dashboard durations by attributing each heartbeat’s capped duration against the complete eligible timeline before applying dimension filters.

  • Uses indexed predecessor lookups for small filtered result sets and window-based attribution for larger sets.
  • Applies consistent attribution to totals, grouped dimensions, weekly projects, and coding rhythm.
  • Versions the dashboard cache key and adds public-behavior coverage for both adaptive paths and timeline eligibility.

Confidence Score: 5/5

The PR appears safe to merge with no outstanding correctness or repository-rule issues.

The filtered dashboard now derives durations from the complete eligible timeline before filtering, and the revised public-behavior tests correctly cover both adaptive query paths. The previous implementation-detail test finding was manually resolved and is not outstanding.

Important Files Changed

Filename Overview
app/services/dashboard_data/snapshots.rb Adds adaptive full-timeline duration attribution and builds all filtered aggregates from the resulting attributed rows.
app/services/dashboard_stats.rb Routes filtered live-dashboard requests through adaptive attribution and versions the corresponding cache entries.
test/services/dashboard_stats_test.rb Verifies externally visible filtered durations, eligibility boundaries, aggregate consistency, and both adaptive threshold paths.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Eligible heartbeat timeline] --> B{Filtered matches ≤ 1000?}
    B -->|Yes| C[Indexed predecessor lookup]
    B -->|No| D[Window attribution over full timeline]
    C --> E[Apply dashboard filters]
    D --> E
    E --> F[Materialized filtered rows]
    F --> G[Totals and grouped dimensions]
    F --> H[Weekly projects]
    F --> I[Coding rhythm]
Loading

Reviews (4): Last reviewed commit: "Fix filtered dashboard durations" | Re-trigger Greptile

Comment thread test/services/dashboard_stats_test.rb Outdated
Base automatically changed from remove-account-merger to main September 6, 2026 12:04
@skyfallwastaken
skyfallwastaken force-pushed the fix-filtered-dashboard-durations branch 2 times, most recently from ddc3bb6 to 55acadb Compare September 6, 2026 12:07
@skyfallwastaken
skyfallwastaken force-pushed the fix-filtered-dashboard-durations branch from 55acadb to 797f7d2 Compare September 6, 2026 12:13
@skyfallwastaken
skyfallwastaken merged commit 6f2eb51 into main Sep 6, 2026
19 checks passed
@skyfallwastaken
skyfallwastaken deleted the fix-filtered-dashboard-durations branch September 6, 2026 12:16
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.

1 participant