Skip to content

Fix time filter to sync across all dashboard views#52

Merged
pineapplestrikesback merged 1 commit intomainfrom
claude/fix-time-filter-views-FoC4F
Jan 27, 2026
Merged

Fix time filter to sync across all dashboard views#52
pineapplestrikesback merged 1 commit intomainfrom
claude/fix-time-filter-views-FoC4F

Conversation

@pineapplestrikesback
Copy link
Owner

@pineapplestrikesback pineapplestrikesback commented Jan 27, 2026

The time filter (This Week/Last 7 Days) in the WeeklyActivityChart now
updates the heatmap and muscle list view as well, not just the bar chart.

  • Added mode parameter to useWorkouts hook supporting calendar week mode
  • Updated useVolumeStats hooks to accept ViewMode parameter
  • Lifted viewMode state from WeeklyActivityChart to Dashboard
  • Passed viewMode to TotalVolumeCard, MuscleHeatmap, and MobileCarousel
  • Updated mobile components (MobileHeatmap, MobileMuscleList, MuscleDetailModal)
    to respect the shared viewMode

https://claude.ai/code/session_019k1SNeEWQfGDPehucnB57U

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for multiple time-range viewing modes: "Last 7 Days" and "Calendar Week" for workout and volume statistics across all charts and visualizations.
    • Enabled view mode switching capability in relevant components, allowing users to toggle between time-range perspectives for better data analysis.
  • Improvements

    • Maintained backward compatibility with existing time-based queries while introducing new mode-based filtering options.

✏️ Tip: You can customize this high-level summary in your review settings.

The time filter (This Week/Last 7 Days) in the WeeklyActivityChart now
updates the heatmap and muscle list view as well, not just the bar chart.

- Added mode parameter to useWorkouts hook supporting calendar week mode
- Updated useVolumeStats hooks to accept ViewMode parameter
- Lifted viewMode state from WeeklyActivityChart to Dashboard
- Passed viewMode to TotalVolumeCard, MuscleHeatmap, and MobileCarousel
- Updated mobile components (MobileHeatmap, MobileMuscleList, MuscleDetailModal)
  to respect the shared viewMode

https://claude.ai/code/session_019k1SNeEWQfGDPehucnB57U
@vercel
Copy link

vercel bot commented Jan 27, 2026

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

Project Deployment Review Updated (UTC)
gym-analytics Ready Ready Preview, Comment Jan 27, 2026 5:33pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces a ViewMode type ('last7days' | 'calendarWeek') to supplement numeric daysBack parameters across hooks and components. It adds backward-compatible mode-based date-range queries in useWorkouts, updates volume-related hooks to accept the new union-typed parameter, and propagates viewMode props through UI components while preserving existing behavior.

Changes

Cohort / File(s) Summary
Core Hooks
src/db/hooks/useWorkouts.ts
Introduces ViewMode type and UseWorkoutsOptions interface; expands useWorkouts API to accept number | UseWorkoutsOptions with backward-compatible fallback; implements mode-specific date-range logic (rolling window vs. calendar week); updates queryKey to differentiate by mode.
src/db/hooks/useVolumeStats.ts
Desktop Components
src/ui/components/MuscleHeatmap.tsx
Adds optional viewMode prop; imports ViewMode type; selects viewMode over daysBack when provided for volume data fetching.
src/ui/components/TotalVolumeCard.tsx
src/ui/components/WeeklyActivityChart.tsx
Mobile Components
src/ui/components/mobile/MobileCarousel.tsx
Adds optional viewMode prop; passes viewMode to child components MobileHeatmap and MobileMuscleList.
src/ui/components/mobile/MobileHeatmap.tsx, src/ui/components/mobile/MobileMuscleList.tsx, src/ui/components/mobile/MuscleDetailModal.tsx
Page
src/ui/pages/Dashboard.tsx
Introduces local ViewMode type and viewMode state (default 'last7days'); propagates viewMode to TotalVolumeCard, WeeklyActivityChart, MobileCarousel, and MuscleHeatmap; implements onViewModeChange handler; updates header text to reflect current mode.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashboard as Dashboard<br/>(viewMode state)
    participant WAC as WeeklyActivityChart<br/>(controlled)
    participant VM as useVolumeStats<br/>Hooks
    participant UW as useWorkouts
    participant API as Data

    User->>Dashboard: select viewMode
    activate Dashboard
    Dashboard->>WAC: viewMode prop
    Dashboard->>VM: daysBackOrMode param
    deactivate Dashboard

    activate WAC
    WAC->>WAC: setViewMode updates<br/>parent state
    deactivate WAC

    activate VM
    VM->>UW: pass viewMode
    deactivate VM

    activate UW
    UW->>UW: Calculate date range<br/>based on mode
    Note over UW: last7days: today-6 to today<br/>calendarWeek: Mon-Sun
    UW->>API: fetch with dateRange
    deactivate UW

    API-->>UW: workouts
    UW-->>VM: workouts[]
    VM-->>Dashboard: stats, totalVolume
    Dashboard->>User: render with new data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through time so free,
With seven days or weeks to see!
Each mode now bends to queries new,
From hooks to UI, props shine through.
swishes whiskers — flexibility's in style! ✨

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pineapplestrikesback pineapplestrikesback merged commit 66254fb into main Jan 27, 2026
3 of 4 checks passed
@claude
Copy link

claude bot commented Jan 27, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

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