Skip to content

Longer Trends ranges with weekly bars and a 7-day average - #8

Draft
Oliver-Johnson wants to merge 7 commits into
masterfrom
claude/trends-more
Draft

Oliver-Johnson wants to merge 7 commits into
masterfrom
claude/trends-more

Conversation

@Oliver-Johnson

Copy link
Copy Markdown
Owner

Checks

  • I have not edited index.html or sw.js without understanding the PWA cache implications
  • The version string in index.html has been bumped (format: Version YYYY-MM-DD.N). Left for promotion, see notes
  • manifest.json is still valid JSON (unchanged)
  • The app works offline after the change (no change to sw.js)
  • CI passes (version consistency, .nojekyll, symlinks, conflict markers)

What this changes

Before: Trends went up to 3 months, one bar per day, and the summary showed only calorie averages.

After:

  • New 6M and 1Y ranges. Beyond 3 months each bar is one week, the average of that week's logged days. Weeks are counted back from today, and the tooltip says how many days that week had entries.
  • A 7-day average calorie line sits over the daily bars, shown once a window has at least 3 logged days. It has its own legend entry.
  • The summary adds average protein, carbs and fat, and "Days logged X of Y".
  • Wide charts show up to 8 date labels, and a label that would crowd the last one is left out.

How: getTrendsDays() gains 182 and 364. trendsByWeek() buckets the daily data, avg7Of() computes the rolling line, and renderTrendsSummary() takes the daily data, so averages stay per-day in weekly mode.

Testing done

  • Seeded a year of data and took screenshots at 1440 and 390 wide, in the default and Bold styles. No page errors or overflow.
  • 40/40 smoke tests on this branch and on the beta build locally (Chromium).
  • Ran CI's checks locally. All pass.

Notes for reviewer

This is a draft. It goes to beta testers first via #9. Before it leaves draft it needs a version bump and a What's New and changelog entry on top of master. This builds on #6, #2 and #1, so its own change is commit f8b0c0b.

🤖 Generated with Claude Code

https://claude.ai/code/session_019C67htt6KV7fmxsGCf5FR7


Generated by Claude Code

claude added 4 commits October 6, 2026 10:04
…6-10-06.1)

seedCustomFoods() ran on every launch and added 11 foods to each user's
custom foods list, re-adding any the user had deleted. The list is now
only used as a fibre lookup. Existing users keep whatever is already in
their list.

Also removes plans/training_plan_2026.md, which held personal health
data, and corrects the v2026-09-02.2 changelog date.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019C67htt6KV7fmxsGCf5FR7
…(v2026-10-06.2)

- Trends and Macro History: dates under the charts were cut off; the
  Trends kg/kcal labels overlapped the top axis values and the end bars
  covered the axis numbers.
- History calendar: an inline padding override put "Jump to Today"
  behind the bottom nav, so tapping it opened Settings.
- Additional Nutrients in Manual and Quick Add never collapsed because
  no .hidden rule existed. It now collapses on tap and stays open by
  default, as users see it today.
- Macro breakdown popup: escape food names before inserting them.
- First-run tour: steps whose target is hidden show the tip centred.
- Ko-fi card on tablets sits above the bottom nav.
- Docs: What's New cards now reveal in Chrome; the observer watched a
  card clipped to nothing, which never intersects.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019C67htt6KV7fmxsGCf5FR7
Wide screens get their own layout in the same app and URL:
- 1024px and up: sidebar nav, centred content, Today split into a main
  column (rings, meals, food log) and a side column (water, exercise,
  notes, averages, weight); sheets open as centred dialogs.
- 768px and up: the phone layout centred, with floating sheets.
- Trends and History charts use a wider viewBox on big screens with
  horizontal date labels, and re-render when the window crosses a
  breakpoint.
- The tour keeps its tooltip clear of the sidebar.

Phones are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019C67htt6KV7fmxsGCf5FR7
- 6M and 1Y ranges. Past 3 months each bar is a week's daily average
  (weeks counted back from today), with the days logged in the tooltip.
- A 7-day average kcal line on the daily ranges.
- The summary adds average macros and days logged.
- Wide charts show 8 date labels, and a label that would crowd the
  last one is left out.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019C67htt6KV7fmxsGCf5FR7
claude added 3 commits October 7, 2026 08:30
- Step through date keys in UTC in getTrendsData and the 7-day average.
  Local setDate steps on UTC-midnight dates skipped or repeated a day
  when a range crossed a DST change, so 6M/1Y (and 2W-3M near a change)
  could drop today, skip a day or count the wrong number of days.
- Include the 7-day average in the kcal axis maximum, so a high week
  just before the range no longer draws the line above the chart.
- Read the daily targets and settings once per render instead of
  re-parsing them for each of up to 364 days.
- Remove the unused avgStart variable.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRtr2mPSPusKdCyJWSbct5
… < 14

MediaQueryList.addEventListener only exists from Safari 14. On older iOS
Safari the top-level call threw a TypeError, which stopped every later
top-level statement in the script, including the tour's visibilitychange
and pagehide listeners that restore real data after the demo.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRtr2mPSPusKdCyJWSbct5
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRtr2mPSPusKdCyJWSbct5

This branch has not been deployed

No deployments
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