From bbf0ccde15994f0d0b352289513ee9d4d2cbdaf9 Mon Sep 17 00:00:00 2001 From: egeakman Date: Tue, 27 May 2025 18:21:57 -0400 Subject: [PATCH] Fix duration of summits and tutorials --- src/models/pretalx.py | 13 +++++++------ src/utils/utils.py | 13 +++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/models/pretalx.py b/src/models/pretalx.py index a925930..560db85 100644 --- a/src/models/pretalx.py +++ b/src/models/pretalx.py @@ -65,7 +65,7 @@ class PretalxSubmission(BaseModel): duration: str = "" resources: list[dict[str, str]] | None = None answers: list[PretalxAnswer] - slot: PretalxSlot | None = Field(..., exclude=True) + slots: list[PretalxSlot] = Field(default_factory=list, exclude=True) slot_count: int = Field(..., exclude=True) # Extracted from slot data @@ -105,11 +105,12 @@ def process_values(cls, values) -> dict: # Set slot information if values.get("slots"): - slot = PretalxSlot.model_validate(values["slots"][0]) - values["slot"] = slot - values["room"] = slot.room - values["start"] = slot.start - values["end"] = slot.end + first_slot = PretalxSlot.model_validate(values["slots"][0]) + values["room"] = first_slot.room + values["start"] = first_slot.start + + last_slot = PretalxSlot.model_validate(values["slots"][-1]) + values["end"] = last_slot.end return values diff --git a/src/utils/utils.py b/src/utils/utils.py index 6be0a1b..82541a5 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -147,16 +147,13 @@ def start_times(session: EuroPythonSession) -> list[datetime]: TODO: We assume a lot of things here, IMHO we should make things more flexible :) """ - session_type = session.session_type.lower() - is_tutorial = "tutorial" in session_type - is_workshop = "workshop" in session_type - - if (is_tutorial or is_workshop) and session.slot_count == 2: - # Half day workshops and tutorials have 2 slots, 90 minutes each, with a 15-minute break in between + if session.slot_count == 2: + # Half day sessions have 2 slots, 90 minutes each, with a 15-minute break in between return [session.start, session.start + timedelta(minutes=90 + 15)] - elif is_workshop and session.slot_count == 4: - # Full day workshops have 4 slots, 90 minutes each, with 15-minute breaks in between, and a 1-hour lunch break after the 2nd slot + elif session.slot_count == 4: + # Full day sessions have 4 slots, 90 minutes each, with a 15-minute break after the first slot, + # a 60-minute lunch break after the second slot, and a 15-minute break after the third slot return [ session.start, session.start + timedelta(minutes=90 + 15),