From 558d076537bae0f9160125b6d360c02570b88ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Thu, 30 Sep 2021 13:55:55 +0200 Subject: [PATCH] API-28: Fixing a bug where an empty week in rapla would make the API return HTTP 500 instead of an empty list --- src/models/dhbw-rapla-changes/changes/changes.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/models/dhbw-rapla-changes/changes/changes.service.ts b/src/models/dhbw-rapla-changes/changes/changes.service.ts index b58ace1..54c38bd 100644 --- a/src/models/dhbw-rapla-changes/changes/changes.service.ts +++ b/src/models/dhbw-rapla-changes/changes/changes.service.ts @@ -25,6 +25,10 @@ export const getChanges = async (course: string, week: string): Promise relevantEventIds.push(row.entry_id); }); + if (relevantEventIds.length < 1) { + return []; + } + let rows = await conn.query('SELECT c.change_id, c.entry_id, c.change_timestamp, c.isDeleted, c.new_summary, c.new_description, c.new_start, c.new_last_modified, c.new_end, c.new_created, c.new_location, c.new_organizer, c.new_categories, e.uid FROM rapla_changes c LEFT OUTER JOIN rapla_entries e ON c.entry_id = e.entry_id WHERE c.entry_id IN (?) ORDER BY c.change_id', [relevantEventIds]); let eventsMap = new Map();