dalsi pokusy
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-23 00:06:30 +02:00
parent 8845350c0b
commit a52be1b792
5 changed files with 119 additions and 12 deletions

View File

@@ -661,17 +661,26 @@ def _pre_negative_sell_export_window(
return first_neg, first_neg - 1
def _prague_calendar_date(slot: PlanningSlot):
dt = slot.interval_start
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
return dt.astimezone(ZoneInfo("Europe/Prague")).date()
def _pre_neg_peak_sell_idx(
slots: list[PlanningSlot],
first_neg_sell_idx: int | None,
) -> int | None:
"""Index slotu s nejvyšším kladným sell před prvním sell<0."""
"""Nejvyšší kladný sell před prvním sell<0 ve stejném kalendářním dni (Prague)."""
if first_neg_sell_idx is None or first_neg_sell_idx <= 0:
return None
neg_day = _prague_calendar_date(slots[first_neg_sell_idx])
positive = [
(i, float(slots[i].sell_price))
for i in range(first_neg_sell_idx)
if float(slots[i].sell_price) >= 0.0
and _prague_calendar_date(slots[i]) == neg_day
]
if not positive:
return None