Repository navigation
feat: add effective-dated nutrition goal history - #243
Open
kgenerozov wants to merge 1 commit into
Open
kgenerozov wants to merge 1 commit into
kgenerozov wants to merge 1 commit into
Conversation
Contributor
|
Thanks, this is a good idea. Dev has moved a lot since you opened it, especially sync and settings, and most of the files now conflict. Could you rebase it onto current dev? I'll review it properly then. |
Contributor
Author
Sure |
Goal history keeps the complete goal configuration in effect on each local calendar day, so a report on a past week compares intake with the target it actually had instead of today's. Several changes in a day collapse to that day's final configuration, and a date before the first snapshot is reported as unknown rather than filled in from today's goals. Resolution reuses the app's own rules (goal-resolver.js, effective-goal.js, adaptive-tdee.js): weekday goals, percent macros, Dynamic and Adaptive calories, and the activity adjustment, read from that day's settings and from the data available up to that date. The no-argument response is unchanged. The app records the day a goal change was made for, so an offline change carries its own date up through the sync push; the server dates a change from an older app in the account's time zone, and only for the newest day history knows. Full backups keep the history. Applying a goal template is one bulk write, which makes one snapshot.
kgenerozov
force-pushed
the
feat/historical-nutrition-goals
branch
from
November 13, 2026 06:37
6884e12 to
a5b2dcf
Compare
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.
Summary
Goal history keeps the nutrition-goal configuration that was in effect on each calendar day, so a report on a past week compares intake with the target it actually had instead of today's. Trace, MCP
get_goalsandGET /api/v1/goalsshare one implementation; the response without a date is unchanged.What changes
goal_history), resolved as the newest snapshot on or before the requested date. Dates before the first snapshot are unknown, never filled in from today's goals.server/lib/setting-merge.js): the direct settings routes, a phone's sync push, a bulk/template, a reset and a day's history all apply an edit by the same rule. Edits are ordered in milliseconds, a tie goes to the arriving edit, a delete wins a tie, and an edit brings a deleted setting back only when it is strictly later. History knows the tombstone too, so a snapshot arriving at the exact instant of a reset can no longer revive a value the live settings keep deleted.wl:settinglistener no longer both write it). A queued write belongs to the account generation captured with the edit and stops if the account moves on; an account switch waits for the queue before counting or clearing the copy.effective_date, else the account's day in itstimezone.Historical semantics
timezone). With notimezoneset yet (the app records one on first launch), the dated forms use UTC on the phone and the server alike, so one edit resolves to one day everywhere. The response without a date keeps the day it always used — the account's zone, else the server's own — and is unchanged.goal-resolver.js,effective-goal.js,adaptive-tdee.js) and only the observations available up to that date; fields are described indocs/public-api.md.GET /api/goals/effectiveneed a signed-in account. In single-user mode (no user management) they are unavailable, as before.Validation
npm test: 2010 tests, 0 fail (branch base 1981): behavioural tests for a delayed direct save, a conflict inside one second in settings and history, a reset whose instant ties an incoming claim, a reset followed by a change to another field and a late edit between them, two browser tabs merging a day with the queue order inverted, one native write per edit, an account switch with a queued write, two native goal edits at once, one moment for a native batch, the real browser queue path, a pre-feature database upgraded in one start, two devices on one day, carried claims, forward propagation and the clock corrections.npm run build,npm run i18n:check: pass.git diff --checkclean; the rebased patch applies cleanly to312b9b2.