Skip to content

Commit

Permalink
update sorting lambda to account for possible None value
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleogenesis committed Jul 3, 2024
1 parent df83c52 commit 6141620
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kolibri/core/exams/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from django.http import Http404
from django.utils.timezone import now
from django_filters.rest_framework import DjangoFilterBackend
Expand Down Expand Up @@ -152,9 +154,10 @@ def list(self, request, *args, **kwargs):

# Consolidate the exam_queryset and draft_queryset
# and sort them by reverse date_created
dt_utc_aware = datetime.datetime.fromtimestamp(0, datetime.timezone.utc)
all_objects = sorted(
[*exam_objects, *draft_objects],
key=lambda x: x["date_created"],
key=lambda x: x["date_created"] or dt_utc_aware,
reverse=True,
)

Expand Down

0 comments on commit 6141620

Please sign in to comment.