From 21fd03f0250745238be7f6761c89fe28a90e2db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Pelay?= Date: Thu, 29 Feb 2024 17:41:45 -0400 Subject: [PATCH 1/2] improve fetching of teacher adventures --- app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 872ca091099..a67beda4416 100644 --- a/app.py +++ b/app.py @@ -1005,10 +1005,15 @@ def programs_page(user): all_programs = DATABASE.filtered_programs_for_user(from_user or username, submitted=submitted, pagination_token=page) - + ids_to_fetch = [] for program in all_programs: - adventure_names[program['adventure_name']] = program['name'] + if 'adventure_name' in program and program['adventure_name'] not in adventure_names: + ids_to_fetch.append(program['adventure_name']) + teacher_adventures = DATABASE.batch_get_adventures(ids_to_fetch) + for id, teacher_adventure in teacher_adventures.items(): + if teacher_adventure is not None: + adventure_names[id] = teacher_adventure['name'] swapped_adventure_names = {value: key for key, value in adventure_names.items()} result = DATABASE.filtered_programs_for_user(from_user or username, level=level, From 108e6da327150f1e0a618a34d07d2c8235d14489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Pelay?= Date: Thu, 29 Feb 2024 17:51:20 -0400 Subject: [PATCH 2/2] fix none being displayed --- templates/htmx-program.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/htmx-program.html b/templates/htmx-program.html index c8d4cb663de..e797e7293c0 100644 --- a/templates/htmx-program.html +++ b/templates/htmx-program.html @@ -16,7 +16,7 @@