Skip to content

Fix supplements auto-adding to daily totals without being taken#217

Merged
d3mocide merged 1 commit into
mainfrom
claude/supplements-auto-add-bug-dpm67n
Jun 16, 2026
Merged

Fix supplements auto-adding to daily totals without being taken#217
d3mocide merged 1 commit into
mainfrom
claude/supplements-auto-add-bug-dpm67n

Conversation

@d3mocide

Copy link
Copy Markdown
Owner

Problem

Supplement nutrients (calories, sat fat, fiber, sugar, protein) were being added to the user's daily totals for every active supplement, regardless of whether the user had actually marked it as taken today. The "did I actually take this today" gate was missing — the code assumed any is_active supplement was consumed.

This is what produced the screenshot the user reported: totals showing supplement-derived nutrients on a day where nothing was logged as taken.

Root cause

backend/luma/api/today.py had two spots that summed nutrients_per_dose over all is_active supplements with no reference to SupplementLog:

  • /today — added all active supplement nutrients unconditionally.
  • /today/streak-history — computed one supplement total and blanket-applied it to every one of the 30 days, which also meant a newly-added supplement retroactively altered past days.

The SupplementLog table and a working POST/DELETE /health/supplements/{id}/log flow already existed (the list endpoint already returns taken_today); the totals calculation simply ignored it.

Fix

  • /today: join SupplementLog and only credit nutrients for active supplements logged as taken within today's local-timezone window.
  • /today/streak-history: build a per-day map of supplement contributions from that day's logs, so each day reflects only what was actually taken (and supplement-only days still count).
  • frontend/src/routes/health.tsx: the Supplements tab now aggregates and labels only supplements taken today ("Taken Today"), and the helper copy/empty states reflect that only supplements you mark as taken are integrated into daily totals.

Verification

  • Backend: test_health_logging.py passes (3 passed); mypy luma/api/today.py --ignore-missing-imports clean; module imports clean.
  • Frontend: pnpm type-check clean, pnpm lint 0 errors, pnpm test 97 passed.

https://claude.ai/code/session_01BLk2x7KN3NanY7HMGwH4ZR


Generated by Claude Code

Supplements were being added to daily totals for every active supplement
regardless of whether the user had actually marked it taken. Both the
/today endpoint and /today/streak-history summed nutrients from all
is_active supplements, missing the "taken today" check.

Now both paths join SupplementLog and only credit nutrients for
supplements the user logged as taken on the relevant day. The streak
history credits each day from that day's logs instead of blanket-applying
one set across all 30 days. The Supplements tab UI is updated to aggregate
and describe only supplements taken today.
@d3mocide d3mocide marked this pull request as ready for review June 16, 2026 14:50
@d3mocide d3mocide merged commit b1c13ad into main Jun 16, 2026
4 checks passed
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