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):
|
||||
"""Flow Viewset"""
|
||||
|
||||
queryset = Flow.objects.all()
|
||||
queryset = Flow.objects.all().prefetch_related("stages")
|
||||
serializer_class = FlowSerializer
|
||||
lookup_field = "slug"
|
||||
ordering = ["slug", "name"]
|
||||
|
|
|
@ -61,7 +61,7 @@ class StageViewSet(
|
|||
filterset_fields = ["name"]
|
||||
|
||||
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)})
|
||||
@action(detail=False, pagination_class=None, filter_backends=[])
|
||||
|
|
Reference in New Issue