Skip to content

Add a weight goal with trend and estimated arrival date - #13

Merged
YarinQuapi merged 2 commits into
masterfrom
scanner-feedback-loop
Nov 16, 2026
Merged

YarinQuapi merged 2 commits into
masterfrom
scanner-feedback-loop

Conversation

@YarinQuapi

Copy link
Copy Markdown
Owner

What

Users can set a target weight on the Weight screen (web and mobile) and see how they are doing against it:

  • progress from where they started to the target,
  • weekly pace,
  • a trend line and goal line on the chart,
  • the estimated date the current pace reaches the goal.

A second commit makes the iOS app build and run on Apple Silicon simulators, which was needed to check the mobile screen.

How the estimate works

  • Pace is a least-squares line through the last 30 days of weigh-ins, so one odd reading does not swing the date. When those span under a week it widens to 90 days.
  • ETA is the date that line reaches the target.
  • No estimate with under a week of weigh-ins ("keep logging"), when flat or moving away from the goal, or when the goal is more than three years out.
  • Progress runs from the weight when the goal was set. Moving the target further the same way keeps the progress made; a goal in the other direction restarts from the current weight.

The logic is weightTrend in apps/api/src/domain.ts, shared by both clients through the API.

API

  • New WeightGoal table (target, start weight, set date). Needs migration 20261115120000_weight_goal.
  • GET /api/weights now also returns goal and trend.
  • PUT /api/weights/goal and DELETE /api/weights/goal set and remove the goal. They reuse the existing weights:create permission rather than adding a new one.

Simulator build

libtesseract has no arm64 simulator slice, and SwiftyTesseract excludes arm64 from every simulator build, leaving an Intel-only app that current simulators refuse to install. On Apple Silicon simulators only, the Podfile drops that exclusion and leaves out the two wrapper files that call Tesseract, and the OCR plugin answers a scan with an error. Label scanning does not work in the simulator; device builds are unchanged.

Testing

  • API: new weightTrend unit tests (on track, window choice, too little data, off track, reached in both directions); typecheck and npm test pass.
  • Web: build passes. Checked in the browser against the local API: set a goal, "keep logging" state, edit, remove. The on-track view (trend line, ETA) was checked with sample data only.
  • Mobile: new widget tests for the goal card in English and Hebrew; flutter analyze and flutter test pass. Run on the iPhone 18 Pro simulator: set a goal, validation error, edit form. Device build (flutter build ios --debug --no-codesign) succeeds.

Not checked: the on-track view on a simulator or device (the test account has one weigh-in), the Hebrew layout on web, and a run on a physical iPhone.

🤖 Generated with Claude Code

YarinQuapi and others added 2 commits November 16, 2026 17:28
libtesseract ships no arm64 simulator slice. SwiftyTesseract answers
that by excluding arm64 from every simulator build, which leaves an
Intel-only app that current iOS simulators refuse to install ("needs to
be updated").

On Apple Silicon simulators only:
- the Podfile drops that arm64 exclusion and leaves out the two
  SwiftyTesseract files that call into libtesseract;
- the OCR plugin builds without libtesseract and answers a scan with an
  error.

Label scanning therefore does not work in the simulator. Device builds
are unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Users can set a target weight on the Weight screen (web and mobile) and
see how they are doing against it: progress from where they started,
weekly pace, a trend line and goal line on the chart, and the date the
current pace reaches the goal.

- API: new WeightGoal table (target, start weight, set date). GET
  /api/weights now also returns the goal and trend; PUT and DELETE
  /api/weights/goal set and remove it, behind the existing
  weights:create permission.
- The pace is a least-squares line through the last 30 days of
  weigh-ins, so one odd reading does not swing the date. It widens to
  90 days when those span under a week, and gives no estimate with less
  than a week of data, when moving away from the goal, or when the goal
  is more than three years out.
- Moving the target further the same way keeps the progress made; a
  goal in the other direction restarts from the current weight.
- Web and mobile: goal card with set, edit and remove; the chart gains
  a dotted goal line, a dashed trend line projected ahead, and a marker
  where the two meet. English and Hebrew.

The mobile weigh-in list also used a hardcoded "kg"; it now uses the
translated unit.

Needs the 20261115120000_weight_goal migration.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@YarinQuapi
YarinQuapi merged commit 919c701 into master Nov 16, 2026
3 checks passed
@YarinQuapi
YarinQuapi deleted the scanner-feedback-loop branch November 16, 2026 15:30
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.

1 participant