Skip to content

Commit da2b764

Browse files
authored
Fix duration of summits and tutorials (#136)
1 parent d4fccea commit da2b764

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/models/pretalx.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class PretalxSubmission(BaseModel):
6565
duration: str = ""
6666
resources: list[dict[str, str]] | None = None
6767
answers: list[PretalxAnswer]
68-
slot: PretalxSlot | None = Field(..., exclude=True)
68+
slots: list[PretalxSlot] = Field(default_factory=list, exclude=True)
6969
slot_count: int = Field(..., exclude=True)
7070

7171
# Extracted from slot data
@@ -105,11 +105,12 @@ def process_values(cls, values) -> dict:
105105

106106
# Set slot information
107107
if values.get("slots"):
108-
slot = PretalxSlot.model_validate(values["slots"][0])
109-
values["slot"] = slot
110-
values["room"] = slot.room
111-
values["start"] = slot.start
112-
values["end"] = slot.end
108+
first_slot = PretalxSlot.model_validate(values["slots"][0])
109+
values["room"] = first_slot.room
110+
values["start"] = first_slot.start
111+
112+
last_slot = PretalxSlot.model_validate(values["slots"][-1])
113+
values["end"] = last_slot.end
113114

114115
return values
115116

src/utils/utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,13 @@ def start_times(session: EuroPythonSession) -> list[datetime]:
147147
148148
TODO: We assume a lot of things here, IMHO we should make things more flexible :)
149149
"""
150-
session_type = session.session_type.lower()
151-
is_tutorial = "tutorial" in session_type
152-
is_workshop = "workshop" in session_type
153-
154-
if (is_tutorial or is_workshop) and session.slot_count == 2:
155-
# Half day workshops and tutorials have 2 slots, 90 minutes each, with a 15-minute break in between
150+
if session.slot_count == 2:
151+
# Half day sessions have 2 slots, 90 minutes each, with a 15-minute break in between
156152
return [session.start, session.start + timedelta(minutes=90 + 15)]
157153

158-
elif is_workshop and session.slot_count == 4:
159-
# 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
154+
elif session.slot_count == 4:
155+
# Full day sessions have 4 slots, 90 minutes each, with a 15-minute break after the first slot,
156+
# a 60-minute lunch break after the second slot, and a 15-minute break after the third slot
160157
return [
161158
session.start,
162159
session.start + timedelta(minutes=90 + 15),

0 commit comments

Comments
 (0)