Skip to content

Fix duration of summits and tutorials #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/models/pretalx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
13 changes: 5 additions & 8 deletions src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down