Fix premature OVERDUE on the API and the Complete tap doing nothing
Overdue: the API read the host clock (the deployed container runs UTC, the household is US Eastern), so every morning quest turned overdue from ~04:00 local, and the snapshot routes built a default settings object instead of the stored one. Add an additive `timezone` setting (IANA name; "" keeps the host-local behaviour), validated through the shared settings field table and exposed on the admin settings GET/PATCH. Every API clock read (panel/admin routes, the missed-sweep scheduler) now re-expresses the one host read in that zone, and the snapshot routes load the persisted settings. Complete: with target ES2022, TypeScript's useDefineForClassFields default emitted the cards' reactive fields as native class fields that shadow Lit's accessors, so setting `_confirm` never re-rendered and the confirm dialog never opened. Set useDefineForClassFields to false (Lit's documented TypeScript setting) and rebuild the bundle. Tests pin the clock at the due-time boundary for both snapshot shapes, cover the scheduler and on-time stamp, and drive the built bundle's Complete tap through to the complete_quest service call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -8,7 +8,8 @@ configured ``day_rollover_time`` — read fresh from the settings store
|
||||
at the top of EVERY cycle, so an admin's settings change applies on
|
||||
the next scheduling decision without a restart — then runs the
|
||||
HA-free core's :func:`nestquest_core.sweep.run_missed_sweep` for the
|
||||
API host's local date and publishes each returned
|
||||
household-local date (the stored ``timezone`` setting; the API host's
|
||||
local date when unset) and publishes each returned
|
||||
``nestquest_quest_missed`` event on the app's ONE transition publisher
|
||||
(the same SSE stream every route publishes through).
|
||||
|
||||
@@ -130,7 +131,11 @@ class MissedSweepScheduler:
|
||||
)
|
||||
await self._sleep(_RETRY_BACKOFF_SECONDS)
|
||||
continue
|
||||
delay = _delay_seconds(rollover, self._clock())
|
||||
# The host may run UTC: the rollover is a household wall-clock
|
||||
# time, so the clock read is re-expressed in the stored zone.
|
||||
delay = _delay_seconds(
|
||||
rollover, settings.household_now(self._clock())
|
||||
)
|
||||
LOGGER.info(
|
||||
"NestQuest missed sweep scheduled for %s (%.0fs from now)",
|
||||
settings.day_rollover_time,
|
||||
@@ -138,7 +143,9 @@ class MissedSweepScheduler:
|
||||
)
|
||||
await self._sleep(delay)
|
||||
try:
|
||||
await self._run_once(self._clock().date())
|
||||
await self._run_once(
|
||||
settings.household_now(self._clock()).date()
|
||||
)
|
||||
except Exception:
|
||||
# Not silent either: the sweep error is logged and the
|
||||
# loop backs off before the next cycle, whose watermark
|
||||
|
||||
Reference in New Issue
Block a user