From dffcf3849e6cfe6a387d22e01377d9d58df6c300 Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Wed, 19 Jun 2024 20:37:56 -0400 Subject: [PATCH] fix: update TimeslotEntry & VirtualTimeslotEntry fields --- program/services.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/program/services.py b/program/services.py index 6e9a0a4c..73198413 100644 --- a/program/services.py +++ b/program/services.py @@ -105,8 +105,9 @@ class ScheduleEntry(TypedDict): class TimeslotEntry(TypedDict): end: str - timeslot_id: int + episode_title: str is_virtual: Literal[False] + memo: str playlist_id: int | None repetition_of_id: int | None schedule_default_playlist_id: int | None @@ -115,10 +116,12 @@ class TimeslotEntry(TypedDict): show_id: int show_name: str start: str + timeslot_id: int class VirtualTimeslotEntry(TypedDict): end: str + episode_title: str is_virtual: Literal[True] show_id: int show_name: str @@ -799,9 +802,11 @@ def make_timeslot_entry(*, timeslot: TimeSlot) -> TimeslotEntry: return TimeslotEntry( end=timeslot.end.strftime("%Y-%m-%dT%H:%M:%S"), + episode_title=timeslot.note.title, is_virtual=False, + memo=timeslot.memo, playlist_id=timeslot.playlist_id, - # 'timeslot.repetition_of` is a foreign key that can be null + # `timeslot.repetition_of` is a foreign key that can be null repetition_of_id=timeslot.repetition_of.id if timeslot.repetition_of else None, schedule_default_playlist_id=schedule.default_playlist_id, schedule_id=schedule.id, @@ -819,9 +824,10 @@ def make_virtual_timeslot_entry(*, gap_start: datetime, gap_end: datetime) -> Vi if radio_settings := RadioSettings.objects.first(): return VirtualTimeslotEntry( end=gap_end.strftime("%Y-%m-%dT%H:%M:%S"), + episode_title=radio_settings.fallback_default_pool, is_virtual=True, show_id=radio_settings.fallback_show.id, - show_name=radio_settings.fallback_default_pool, + show_name=radio_settings.fallback_show.name, start=gap_start.strftime("%Y-%m-%dT%H:%M:%S"), ) else: @@ -868,6 +874,8 @@ def get_timerange_timeslot_entries( timeslot_entries.append( make_virtual_timeslot_entry(gap_start=current.end, gap_end=upcoming.start) ) + else: + timeslot_entries.append(make_timeslot_entry(timeslot=first_timeslot)) # gap after the last timeslot last_timeslot = timeslots.last() -- GitLab