Fixed the courseSegmentInstance sorting bug and added reasoning for sorting in the first place

This commit is contained in:
Erik Thuning 2023-08-29 11:23:04 +02:00
parent c0fe9a8cb1
commit deeb55b73f

@ -97,9 +97,13 @@ class Daisy:
# This should be replaced by an API lookup
booking['educationalType'] = eduTypes[booking['educationalType']]
# If a lecture belongs to more than one course, there will be one
# booking for each course, all with identical times.
# Sorting on courseSegmentInstance ensures that we return a consistent
# course in such cases.
def booking_sort(booking):
if booking['courseSegmentInstances']:
return booking['courseSegmentInstances'][0]['id']
return booking['courseSegmentInstances'][0]['designation']
return ''
Fit = namedtuple('Fit', ['booking', 'overlap'])