Skip to content

Conversation

oliveror
Copy link
Member

Changes

  • Scaled ingredient amounts below 0.005 were rounded to 0 on the detail page (e.g. ⅛ tsp for four scaled to one serving).
  • Scaling and rounding moved to a pure module, apps/web/src/lib/recipeScaling.ts:
    • 200 and above → nearest 5; 50–199 → whole numbers; 3–49 → one decimal; 0.1–3 → two decimals (unchanged rules)
    • below 0.1 → two significant figures, so a positive amount is never shown as 0
    • float noise removed (0.3, not 0.30000000000000004); tiny values print as decimals, not 1e-7
  • Scaling always starts from the stored original amount, so changing servings back and forth does not drift (this was already true and is now covered by tests).

Validation

  • npm run check passes (216 unit tests), incl. new tests for small amounts, fractions, large quantities (up to the API maximum × 1 000 servings) and repeated scaling.

AI usage

Written with Claude Code (Anthropic) to address a teammate's review of the final-delivery findings. Please review the diff as you would any other contribution.

Closes #100

Scaled amounts below 0.005 were rounded to 0 (e.g. 1/8 tsp scaled down).
Scaling and rounding move to a pure, tested lib/recipeScaling.ts: larger
amounts keep the existing rounding steps, amounts below 0.1 use two
significant figures, float noise is removed, and very small values print
as decimals. Scaling always starts from the stored amount.

Closes #100
@oliveror oliveror requested a review from a team as a code owner November 16, 2026 14:10
@olestan olestan merged commit f323fa1 into dev Nov 16, 2026
2 checks passed
@olestan olestan deleted the fix/recipe-quantity-scaling branch November 16, 2026 19:06
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants