From fafc714ec55792b52a77b93872d245c6afd47777 Mon Sep 17 00:00:00 2001
From: Felix Blanke <info@fblanke.de>
Date: Wed, 22 Jan 2025 12:01:05 +0100
Subject: [PATCH] Check that solver duration is not shorter than slot duration

---
 AKModel/models.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/AKModel/models.py b/AKModel/models.py
index b0460541..05a5b28c 100644
--- a/AKModel/models.py
+++ b/AKModel/models.py
@@ -403,10 +403,15 @@ class Event(models.Model):
         for scheduled_slot in schedule["scheduled_aks"]:
             scheduled_slot["timeslot_ids"] = list(map(int, scheduled_slot["timeslot_ids"]))
             start_timeslot = timeslot_dict[min(scheduled_slot["timeslot_ids"])].avail
+            end_timeslot = timeslot_dict[max(scheduled_slot["timeslot_ids"])].avail
 
             slot = AKSlot.objects.get(id=int(scheduled_slot["ak_id"]))
             slot.room = Room.objects.get(id=int(scheduled_slot["room_id"]))
             slot.start = start_timeslot.start
+
+            solver_duration = (end_timeslot.end - start_timeslot.start).total_seconds() / 3600.0
+            assert solver_duration >= slot.duration
+
             slot.save()
 
 class AKOwner(models.Model):
-- 
GitLab