rozsireni o predpovidani posilani

This commit is contained in:
lachtan
2026-06-10 10:54:21 +02:00
parent 10801da03e
commit b0a93dbc15
6 changed files with 337 additions and 11 deletions

View File

@@ -86,6 +86,21 @@ def minutes_to_hhmm(total: int) -> str:
return f"{total // 60:02d}:{total % 60:02d}"
def random_cfg_from_row(row) -> dict:
"""Build a compute_fire_times config from a schedule_random DB row."""
cfg = {
"times_per_day": row["times_per_day"],
"window": f"{minutes_to_hhmm(row['window_start'])}-{minutes_to_hhmm(row['window_end'])}",
}
if row["days_filter"]:
cfg["days"] = row["days_filter"]
if row["from_date"]:
cfg["from"] = row["from_date"]
if row["until_date"]:
cfg["until"] = row["until_date"]
return cfg
def _minute_to_time(total_minutes: int) -> time:
return time(total_minutes // 60, total_minutes % 60)