Public Access
docs: document unit conversion implementation
- Update implementation-plan.md: mark unit conversion complete - Update HANDOFF.md: add session notes for 2026-05-24 unit conversion - Update README.md: list Unit Conversion as a feature
This commit is contained in:
@@ -293,6 +293,29 @@ Trust the tests. Trust the live runs. Don't trust prose claims that something is
|
||||
|
||||
---
|
||||
|
||||
## New session: 2026-05-24
|
||||
|
||||
### Unit conversion implementation
|
||||
Completed implementation of recipe-to-grocery unit conversion to make cost estimates accurate.
|
||||
|
||||
**Files added:**
|
||||
- `backend/app/utils/units.py` — `UnitConverter` class
|
||||
- Normalization: maps synonyms to canonical units (e.g. "TBS" → "tbsp", "pounds" → "lb")
|
||||
- Within-family linear conversion: lb↔oz↔g, cup↔tbsp↔tsp, dozen↔ea
|
||||
- Cross-family via density tables for ~30 canonical ingredients (e.g. rice cup→lb via 185g/cup / 453.592g/lb)
|
||||
- Fallback to dimensionless qty when conversion is impossible (preserves monotonic ranking signal)
|
||||
|
||||
**Files modified:**
|
||||
- `backend/app/services/planner/cost.py` — multiplies `current_price` by `convert_qty(qty, recipe_unit, grocery_unit, ingredient_name)`
|
||||
- `backend/app/services/planner/generate.py` — `_load_match_index` now joins `Ingredient` table and returns `ingredient_name` + `grocery_unit` for each match
|
||||
- `backend/app/services/orchestrator/steps.py` — both email cost block and shopping-list total now use unit conversion
|
||||
- `backend/tests/test_planner_cost.py` — updated fixture to include new fields
|
||||
- `backend/tests/test_units.py` — 19 tests covering normalization, within-family, density, and fallback
|
||||
|
||||
**Test results:** `test_units.py` 19/19 pass; planner cost/score/select 36 passed.
|
||||
|
||||
---
|
||||
|
||||
## New session: 2026-05-23
|
||||
|
||||
### Context
|
||||
|
||||
Reference in New Issue
Block a user