Join across the InstanceLink.target to the underlying Instance

to avoid having to do a lookup for every instance in the list for the
mesh visualizer endpoint.
This commit is contained in:
Jeff Bradberry 2024-01-15 17:10:08 -05:00 committed by Seth Foster
parent 7a1ed406da
commit 8c7c00451a

View File

@ -17,7 +17,7 @@ class MeshVisualizer(APIView):
def get(self, request, format=None):
data = {
'nodes': InstanceNodeSerializer(Instance.objects.all(), many=True).data,
'links': InstanceLinkSerializer(InstanceLink.objects.select_related('target', 'source'), many=True).data,
'links': InstanceLinkSerializer(InstanceLink.objects.select_related('target__instance', 'source'), many=True).data,
}
return Response(data)