Skip to content

Commit 5594438

Browse files
authored
Merge pull request #92 from filips123/fix-empty-lunch-time
2 parents 298647c + d8a7802 commit 5594438

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

API/gimvicurnik/blueprints/calendar.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,20 @@ def create_schedule_calendar(
201201
span.set_tag("event.time", model.time)
202202
span.set_data("event.source", model)
203203

204+
# Skip schedules without time
205+
if not model.time:
206+
logger.debug(
207+
"Skipping iCalendar event",
208+
extra={"type": "lunch-schedule", "source": model},
209+
)
210+
211+
continue
212+
204213
logger.debug(
205214
"Preparing iCalendar event",
206215
extra={"type": "lunch-schedule", "source": model},
207216
)
208217

209-
# Assert date and time exist, so mypy does not complain
210-
if typing.TYPE_CHECKING:
211-
assert model.date
212-
assert model.time
213-
214218
# Create event and add internal properties
215219
event = Event()
216220
event.add("DTSTAMP", datetime.now())

API/gimvicurnik/blueprints/schedule.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_lunch_schedule(date: datetime.date) -> list[dict[str, Any]]:
2323
{
2424
"class": model[1],
2525
"date": model[0].date.strftime("%Y-%m-%d"),
26-
"time": model[0].time.strftime("%H:%M"),
26+
"time": model[0].time.strftime("%H:%M") if model[0].time else None,
2727
"location": model[0].location,
2828
"notes": model[0].notes,
2929
}
@@ -41,7 +41,7 @@ def get_lunch_schedule_for_classes(date: datetime.date, classes: list[str]) -> l
4141
{
4242
"class": model[1],
4343
"date": model[0].date.strftime("%Y-%m-%d"),
44-
"time": model[0].time.strftime("%H:%M"),
44+
"time": model[0].time.strftime("%H:%M") if model[0].time else None,
4545
"location": model[0].location,
4646
"notes": model[0].notes,
4747
}

website/src/store/modules/storage.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export interface DisplayedLesson {
3737
export interface LunchSchedule {
3838
class: string;
3939
date: string;
40-
time: string;
41-
location: string;
40+
time: string | null;
41+
location: string | null;
4242
notes: string | null;
4343
}
4444

0 commit comments

Comments
 (0)