mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-24 13:06:22 +01:00
Pulls the day's delivered dishes and their real per-portion macros out of
panel.kuchniavikinga.pl, so a catering meal is one keypress instead of five
retyped numbers.
A delivered meal is not an eaten meal, so nothing is ever logged unattended:
dishes land in the *curated* bank, and entries are written only after an
explicit confirmation. Auto-logging would let the gate satisfy its own
checkpoint from a delivery note, and would record what the courier dropped off
rather than what was eaten.
Three surfaces:
- `diet-guard kuchnia [--log] [--yes]`
- the lock screen's "Today's delivery" button, which prefills the meal form
dish by dish (the user still clicks Log & Continue)
- a warm-up after each logged meal, on the existing background thread
All event-driven; no new systemd timer. The two automatic paths go through
`refresh_delivery_once`, guarded to one fetch per day.
The panel is an undocumented white-labelled Dietly API; the endpoint map was
recovered from its JS bundles and confirmed against live responses. Notes,
including the traps, are in docs/kuchnia-wikinga.md.
Load-bearing details:
* Macros are per portion and `weight` is that portion in grams -- proven, not
assumed: 4P+4C+9F reproduces the stated calories within ~1% on every meal of
the captured day. `_energy_is_consistent` re-runs that check per dish and
drops any that fails; a per-100g mix-up is invisible in a payload and would
silently skew every logged meal by a factor of several.
* `bank_dishes` compares nutritional fields before calling `add_manual_entry`,
which restamps `t` unconditionally. Without the compare, every refresh
republishes the whole curated bank to every peer. Tests assert on call count.
* Duplicate log suppression reads today's synced log, not a local marker:
`log_meal` mints a fresh uuid, so a re-import after marker loss would merge
as duplicates on every peer.
* The gate hook is in `on_focus_ready`, not `_cli_gate._should_lock`:
`gate_is_due()` never reads the food bank, so a refresh there could not
change the lock decision while adding a third-party round trip to the ~105ms
`gate --check` fast path.
* `requests` is lazy-imported so the gate's not-due tick does not pay for it.
* Credentials and the cached session cookie live in ~/.config/diet_guard at
mode 600, outside the synced tree. The credentials file is written by hand,
never by the package -- the same contract as sync_token.
`_GateDashboard` is merged into `_GateMealFlow`, and both "pull it in from
elsewhere" flows share one `_PullFlows` mixin: pylint's max-parents counts
every MRO entry, so the gate's controller chain had no room for a new class.
Also adds a side-by-side row for the two pull buttons -- stacking them cost
42px and pushed the tab past the viewport at 1366x768.
989 tests, 100% branch coverage, pre-commit clean.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _gate_fixtures.py | ||
| _gate_focus_probe.py | ||
| _gate_keyboard_probe.py | ||
| _gate_layout_probe.py | ||
| _gate_measurement.py | ||
| _kuchnia_fakes.py | ||
| _sync_fakes.py | ||
| _tk_fakes_canvas.py | ||
| _tk_fakes_containers.py | ||
| _tk_fakes.py | ||
| conftest.py | ||
| test_averages_report.py | ||
| test_averages.py | ||
| test_budget_history_io.py | ||
| test_budget_history.py | ||
| test_budget.py | ||
| test_calendar_averages.py | ||
| test_calendar_view.py | ||
| test_cli_averages.py | ||
| test_cli_gate.py | ||
| test_cli_sync.py | ||
| test_cli.py | ||
| test_daystatus.py | ||
| test_estimator.py | ||
| test_foodbank_manual.py | ||
| test_foodbank_rebuild.py | ||
| test_foodbank.py | ||
| test_fuzzy.py | ||
| test_gate_layout_fits.py | ||
| test_gate_tk_modules.py | ||
| test_gate.py | ||
| test_gatelock_calendar.py | ||
| test_gatelock_dashboard.py | ||
| test_gatelock_fanout.py | ||
| test_gatelock_form.py | ||
| test_gatelock_groups.py | ||
| test_gatelock_keyboard.py | ||
| test_gatelock_mealflow.py | ||
| test_gatelock_scheduleedit.py | ||
| test_gatelock.py | ||
| test_kuchnia_autoload.py | ||
| test_kuchnia_cli.py | ||
| test_kuchnia_client.py | ||
| test_kuchnia_gate.py | ||
| test_kuchnia_import.py | ||
| test_kuchnia_orders.py | ||
| test_kuchnia_parse.py | ||
| test_main.py | ||
| test_mcp_averages.py | ||
| test_mcp.py | ||
| test_meal_schedule_store.py | ||
| test_meal_schedule.py | ||
| test_portions.py | ||
| test_prune_peers.py | ||
| test_resolve.py | ||
| test_slots.py | ||
| test_state_redirect.py | ||
| test_state_sync.py | ||
| test_state_today.py | ||
| test_state.py | ||
| test_sync_backend.py | ||
| test_sync_banks_mirror.py | ||
| test_sync_banks.py | ||
| test_sync_budget.py | ||
| test_sync_device_id.py | ||
| test_sync_events.py | ||
| test_sync_merge_banks.py | ||
| test_sync_merge_budget.py | ||
| test_sync_merge_schedule.py | ||
| test_sync_merge.py | ||
| test_sync_pull.py | ||
| test_sync_refresh.py | ||
| test_sync.py | ||
| test_test_guard.py | ||