Skip to content

Filter cycling analytics to cycling activities - #1558

Merged
Asherlc merged 7 commits into
mainfrom
Asherlc/cycling-page-filters
Jul 8, 2026
Merged

Asherlc merged 7 commits into
mainfrom
Asherlc/cycling-page-filters

Conversation

@Asherlc

@Asherlc Asherlc commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Fixes the cycling training page so server-side analytics only include cycling activity types instead of broad endurance activity types. This updates power, estimated threshold power, fitness/fatigue/form, aerobic efficiency, vertical ascent, variability, pedal dynamics, and the power-curve fallback sample path. The root cause was reuse of ENDURANCE_ACTIVITY_TYPES in repositories backing /training/cycling, which allowed walks/runs/hikes into cycling charts. Validated with focused Vitest coverage, TypeScript, and Biome; full changed lint reached analytics SQL lint but local ClickHouse was unavailable at 127.0.0.1:8123.


Summary by cubic

Filters cycling training analytics to cycling-only activities so runs, walks, and hikes no longer affect cycling charts. Applies to power and power curve, eFTP, PMC (fitness/fatigue/form), aerobic efficiency, vertical ascent, variability, pedal dynamics, ramp rate, and training monotony.

  • Bug Fixes
    • Replaced ENDURANCE_ACTIVITY_TYPES with CYCLING_ACTIVITY_TYPES across Power, Efficiency, CyclingAdvanced, and PMC repositories, plus raw activity counts; standardized SQL to has({activityTypes:Array(String)}, ...).
    • Power curve and normalized power: read model now joins analytics.activity_summary (no FINAL) and filters to cycling; ActivitySensorStore.getPowerCurveSamples(days, userId, timezone, activityTypes) added and wired through clickhouse-activity-sensor-analytics and limited-activity-sensor-store.
    • Ramp rate and training monotony now compute from analytics.daily_endurance_load joined to analytics.activity_summary, filtered to cycling; ramp rate window bounded to days + 42 for stable CTL deltas; PMC filters activity queries and the fallback max HR baseline to cycling. Tests updated to assert cycling-only behavior, the new activityTypes param, and update the dedup integration to recognize the cycling ramp rate query.

Written for commit 265e8fd. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Cycling-related analytics and training metrics now use cycling-specific activity filtering for more accurate results.
    • Power curve, eFTP, PMC, efficiency, and advanced cycling metrics now stay aligned across reports.
  • Bug Fixes

    • Fixed inconsistent activity selection in several charts and summaries.
    • Improved history checks so metric calculations better handle available data windows.
  • Tests

    • Expanded automated coverage for cycling-only filtering and query behavior.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Asherlc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 76104208-6582-456a-8d62-e9a7f0e8e018

📥 Commits

Reviewing files that changed from the base of the PR and between 4df858f and 265e8fd.

📒 Files selected for processing (14)
  • packages/server/src/repositories/activity-repository.ts
  • packages/server/src/repositories/clickhouse-activity-sensor-analytics.ts
  • packages/server/src/repositories/clickhouse-activity-sensor-store.test.ts
  • packages/server/src/repositories/clickhouse-activity-sensor-store.ts
  • packages/server/src/repositories/cycling-advanced-repository.test.ts
  • packages/server/src/repositories/cycling-advanced-repository.ts
  • packages/server/src/repositories/efficiency-repository.test.ts
  • packages/server/src/repositories/efficiency-repository.ts
  • packages/server/src/repositories/limited-activity-sensor-store.ts
  • packages/server/src/repositories/pmc-repository.test.ts
  • packages/server/src/repositories/pmc-repository.ts
  • packages/server/src/repositories/power-repository.test.ts
  • packages/server/src/repositories/power-repository.ts
  • packages/server/src/routers/activity-dedup.integration.test.ts
📝 Walkthrough

Walkthrough

Repositories that query ClickHouse for cycling analytics are refactored to filter by an explicit activityTypes parameter rather than internal endurance-type constants. ActivitySensorStore.getPowerCurveSamples gains an activityTypes parameter threaded through ClickHouse implementations. CyclingAdvancedRepository, EfficiencyRepository, PmcRepository, and PowerRepository switch from endurance to cycling activity types, and getRampRate/getTrainingMonotony are recomputed inline instead of reading precomputed weekly tables.

Changes

Cycling-only activity type filtering

Layer / File(s) Summary
ActivitySensorStore contract and ClickHouse power curve query
packages/server/src/repositories/activity-repository.ts, packages/server/src/repositories/clickhouse-activity-sensor-analytics.ts, packages/server/src/repositories/clickhouse-activity-sensor-store.test.ts
getPowerCurveSamples signature and userWindowParams/getClickHousePowerCurveSamples/getClickHouseNormalizedPowerSamples gain an activityTypes parameter, replacing internal ENDURANCE_ACTIVITY_TYPES binding with the caller-supplied array bound as activityTypes in the has(...) SQL filter.
Store implementations forwarding activityTypes
packages/server/src/repositories/clickhouse-activity-sensor-store.ts, packages/server/src/repositories/limited-activity-sensor-store.ts
ClickHouseActivitySensorStore and LimitedActivitySensorStore forward the new activityTypes argument to their respective delegates.
CyclingAdvancedRepository cycling-type filtering and ramp/monotony rework
packages/server/src/repositories/cycling-advanced-repository.ts, cycling-advanced-repository.test.ts, activity-dedup.integration.test.ts
Imports CYCLING_ACTIVITY_TYPES; getRampRate and getTrainingMonotony are recomputed inline from daily_endurance_load joined to activity_summary instead of reading weekly_endurance_ramp_rate/weekly_training_monotony; all query filters/params switch from enduranceTypes to activityTypes; tests and integration mock updated accordingly.
EfficiencyRepository cycling-type filtering
packages/server/src/repositories/efficiency-repository.ts, efficiency-repository.test.ts
getAerobicEfficiency, getAerobicDecoupling, getPolarizationTrend, and diagnostics helpers switch SQL filters/params from endurance to cycling types; new tests validate cycling-only filtering.
PmcRepository cycling-type filtering
packages/server/src/repositories/pmc-repository.ts, pmc-repository.test.ts
getChart queries and #loadRawActivityCount add has(activityTypes...) filters using CYCLING_TYPES; tests refactored with a findQueryCall() helper and cycling-only assertions.
PowerRepository cycling-type filtering
packages/server/src/repositories/power-repository.ts, power-repository.test.ts
getPowerCurve read-model query joins activity_summary and filters by CYCLING_TYPES; getEftpTrend and #loadRawActivityCount similarly filter by cycling types; fallback getPowerCurveSamples call passes CYCLING_TYPES.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • Asherlc/dofek#1174: Both PRs modify ClickHouse power-curve/normalized-power query logic in the same repository files.
  • Asherlc/dofek#1374: Related changes to cycling-advanced-repository.ts pulling from analytics.activity_summary columns.
  • Asherlc/dofek#1531: Both PRs touch the activity_power_curve read-model and getPowerCurveSamples fallback path.

Suggested labels: area/server, type/bug, breaking-change

Suggested reviewers: cubic-dev-ai


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.

@sourcery-ai sourcery-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.

Sorry @Asherlc, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@Asherlc
Asherlc marked this pull request as ready for review July 8, 2026 19:01
Copilot AI review requested due to automatic review settings July 8, 2026 19:01
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread packages/server/src/repositories/cycling-advanced-repository.ts
Comment thread packages/server/src/repositories/efficiency-repository.ts
Comment thread packages/server/src/repositories/limited-activity-sensor-store.ts
Comment thread packages/server/src/repositories/pmc-repository.test.ts Outdated
Comment thread packages/server/src/repositories/pmc-repository.ts
Comment thread packages/server/src/repositories/pmc-repository.ts
Comment thread packages/server/src/repositories/power-repository.ts
Comment thread packages/server/src/repositories/power-repository.ts
@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Storybook previews for e4aa5c64 are ready:

This comment updates automatically on each PR push.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 13 files

Confidence score: 5/5

  • Safe to merge after the addressed issues were fixed.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/server/src/repositories/efficiency-repository.ts Outdated
Comment thread packages/server/src/repositories/cycling-advanced-repository.ts
Comment thread packages/server/src/repositories/pmc-repository.ts
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread packages/server/src/repositories/power-repository.ts
Comment thread packages/server/src/repositories/power-repository.ts

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 4 unresolved issues from previous reviews.

Re-trigger cubic

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 4 unresolved issues from previous reviews.

Re-trigger cubic

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread packages/server/src/repositories/cycling-advanced-repository.ts
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Asherlc

Asherlc commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

Addressed the actionable items from the Cubic review summary.

  • Fixed normalized-power query parameter binding.
  • Fixed remaining cycling-only gaps in efficiency decoupling/polarization, PMC max-heart-rate fallback, ramp rate, and training monotony.
  • Added focused regression tests for those query contracts.
  • Commits: 8d66e8c and c56f144

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/server/src/repositories/cycling-advanced-repository.ts
Comment thread packages/server/src/repositories/pmc-repository.test.ts Outdated
@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Comment thread packages/server/src/routers/activity-dedup.integration.test.ts

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 2 unresolved issues from previous reviews.

Re-trigger cubic

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Asherlc has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 3 files (changes from recent commits).

Auto-approved: Bug fix filtering cycling analytics to cycling-only activities by replacing ENDURANCE_ACTIVITY_TYPES with CYCLING_ACTIVITY_TYPES across six repositories, with updated SQL joins and test coverage.

Re-trigger cubic

@Asherlc
Asherlc merged commit 910fa33 into main Jul 8, 2026
106 checks passed
@Asherlc
Asherlc deleted the Asherlc/cycling-page-filters branch July 8, 2026 20:38
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