flows: optimise queries for flow and stage API endpoints
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
26adf3f774
commit
53aef73f58
|
@ -80,7 +80,7 @@ class FlowSerializer(ModelSerializer):
|
||||||
class FlowViewSet(UsedByMixin, ModelViewSet):
|
class FlowViewSet(UsedByMixin, ModelViewSet):
|
||||||
"""Flow Viewset"""
|
"""Flow Viewset"""
|
||||||
|
|
||||||
queryset = Flow.objects.all()
|
queryset = Flow.objects.all().prefetch_related("stages")
|
||||||
serializer_class = FlowSerializer
|
serializer_class = FlowSerializer
|
||||||
lookup_field = "slug"
|
lookup_field = "slug"
|
||||||
ordering = ["slug", "name"]
|
ordering = ["slug", "name"]
|
||||||
|
|
|
@ -61,7 +61,7 @@ class StageViewSet(
|
||||||
filterset_fields = ["name"]
|
filterset_fields = ["name"]
|
||||||
|
|
||||||
def get_queryset(self): # pragma: no cover
|
def get_queryset(self): # pragma: no cover
|
||||||
return Stage.objects.select_subclasses()
|
return Stage.objects.select_subclasses().prefetch_related("flow_set")
|
||||||
|
|
||||||
@extend_schema(responses={200: TypeCreateSerializer(many=True)})
|
@extend_schema(responses={200: TypeCreateSerializer(many=True)})
|
||||||
@action(detail=False, pagination_class=None, filter_backends=[])
|
@action(detail=False, pagination_class=None, filter_backends=[])
|
||||||
|
|
Reference in New Issue