Commit Graph
8 Commits
Author SHA1 Message Date
dgtlmoonandClaude Opus 5.5 ab06c89c73 Watch time_schedule_limit - Typed, frozen pydantic model with shared defaults, halves per-watch memory
Every watch carried its own copy of the 7-day schedule (15 nested dicts, ~30 strings),
about 3.7KiB of a ~7.6KiB watch, even though nearly every schedule is the untouched
default. At 40,000 watches that is ~146MB.

time_schedule_limit is now a slots + frozen pydantic dataclass (model/TimeScheduleLimit.py)
built on a small generic base (model/shared_defaults.py):

- Anything equal to the default is the one shared default instance, recursively, so an
  untouched day or the whole default schedule costs nothing per watch.
- watch.json only stores what differs from the default (exclude_defaults), an enabled
  schedule with default days is {"enabled": true}, a disabled custom week is kept.
- Frozen, so the shared default can never be mutated in place, assign a new value.
- Every write path (loading, edit form, API, clone) converts in watch_base __setitem__/update.
- Blank/None fields fall back per field, one empty value no longer loses the whole week.
- hours/minutes are ints, in the model, the form and the API spec (no upper bound,
  multi-day windows are supported).
- The scheduler converts the global schedule once per pass instead of reading it per watch.

update_34 rewrites watch.json/tag.json compact and converts the global schedule's
"24"/"00" strings to ints.

Measured: 7.6KiB -> 3.9KiB per watch (296MiB -> 150MiB at 40k watches).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 12:00:22 +02:00
dgtlmoon 227b011d73 Memory usage - small improvement by tidying up module imports (#4352) 2026-09-01 17:50:50 +02:00
dgtlmoon dce6f23cf9 Scheduler+API Bug - if an invalid timezone was set (through edit of watch or API) it could have crashed the scheduler, Added timezone to the official API docs (#4350)
* Scheduler+API Bug - if an invalid timezone was set (through edit of watch or API) it could have crashed the scheduler, Added `timezone` to the official API docs

* adding missing files
2026-09-01 17:00:03 +02:00
dgtlmoon c6d6ef0e0c Fix time schedule off-by-one bug at exact end times for all durations and add comprehensive edge case tests Re #846 (#3890) 2026-02-17 02:38:16 +01:00
dgtlmoon ee824c856b Time scheduler - Remove cache on time lookup 2025-11-03 18:56:37 +01:00
dgtlmoon f304ae19db Adding small amount of cache to common functions (#3565) 2025-10-28 10:43:20 +01:00
dgtlmoon 64350a2e78 Replace jinja2-time with arrow and improve timedate timezone integration, fixes timezones in templates such as {% now 'Europe/London', '%Y-%m-%d' %} etc (#3496) 2025-10-13 11:52:02 +02:00
dgtlmoon 7421e0f95e New functionality - Time (weekday + time) scheduler / duration (#2802) 2024-12-03 12:45:28 +01:00