Skip to content
Snippets Groups Projects
Commit 435e72d5 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

fix: return deterministic result set for episode has_timeslots filter

For some reason the episode result set was unstable when using the
has_timeslots filter. Additionally, the former solution always added a
join to the query, even if the the has_timeslots filter wasn’t used.
parent bd3f6e39
No related branches found
No related tags found
No related merge requests found
Pipeline #9113 passed
Pipeline: aura-tests

#9114

    ......@@ -299,7 +299,8 @@ class EpisodeFilterSet(StaticFilterHelpTextMixin, filters.FilterSet):
    field_name="timeslots",
    help_text="Return only episodes that belong to the specified timeslot(s).",
    )
    has_timeslots = filters.BooleanFilter(
    has_timeslots = StaticQueryBooleanFilter(
    query=Exists(models.TimeSlot.objects.filter(episode=OuterRef("pk"))),
    label="Has timeslots",
    help_text="Returns only timeslots that either have or have not any timeslots.",
    )
    ......
    ......@@ -46,7 +46,6 @@ from rest_framework.response import Response
    from django.conf import settings
    from django.contrib.auth.models import User
    from django.db import IntegrityError
    from django.db.models import Q
    from django.http import HttpResponseRedirect, JsonResponse
    from django.shortcuts import get_object_or_404
    from django.utils import timezone
    ......@@ -1449,7 +1448,7 @@ class EpisodeOwnershipPermission(ShowOwnershipPermission):
    destroy=extend_schema(summary="Delete an existing episode."),
    )
    class APIEpisodeViewSet(viewsets.ModelViewSet):
    queryset = Episode.objects.all().annotate(has_timeslots=Q(timeslots__isnull=True)).distinct()
    queryset = Episode.objects.all()
    pagination_class = LimitOffsetPagination
    serializer_class = EpisodeSerializer
    filter_backends = [DjangoFilterBackend, drf_filters.SearchFilter]
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment