fix(activity): correct Year trends per-day average for the current month - #79
Merged
Merged
Conversation
The 12-month (Year) trends builder divided every month's total by its full calendar length. For the in-progress current month that spread a partial total across 30/31 days, understating the current-month steps/day bar by up to ~3x and dragging down the Year "avg/day" headline. Divide the current month by elapsed calendar days (day-of-month) instead; completed months keep their full calendar length, matching the existing "total ÷ calendar days in period" convention. No other range affected.
saksham2001
approved these changes
Jul 12, 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.
Bug
In the Activity Year (12-month) trends, each month's total was divided by its full calendar length. For the in-progress current month this spread a partial-month total across 30/31 days — understating the current-month steps/day bar by up to ~3× (e.g. on the 10th:
total/31instead oftotal/10) and mildly dragging down the Year "avg/day" headline.Only the current month was affected; completed months were correct. Bug is specific to the
.twelveMonthsbuilder — Day/Week/Month ranges were fine.Fix
Divide the in-progress current month by elapsed calendar days (day-of-month); completed months keep their full calendar length. This matches the existing "total ÷ calendar days in period" convention (completed months already divide by full length regardless of data gaps).
Validation
elsebranch is byte-identical to before — no regression.isCurrentMonthselects exactly the one current year+month bucket (sameCalendar.currentthroughout — no tz/DST/rollover misfire).dailyAverage) and distance/calories inherit the corrected value; no other consumers affected.