From dff1328a2bf45f18b0d81901e617bb1ddf71d1c9 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Thu, 23 Dec 2021 16:44:12 +0000 Subject: [PATCH] Select extra columns to avoid further queries --- jobserver/api/releases.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jobserver/api/releases.py b/jobserver/api/releases.py index c6276f5ef..32c71ef8a 100644 --- a/jobserver/api/releases.py +++ b/jobserver/api/releases.py @@ -239,7 +239,7 @@ def get(self, request, release_id): """A list of files for this Release.""" release = get_object_or_404(Release, id=release_id) validate_release_access(request, release.workspace) - files = {f.name: f for f in release.files.all()} + files = {f.name: f for f in release.files.select_related("created_by")} return Response(generate_index(files)) @@ -261,7 +261,7 @@ def get(self, request, *args, **kwargs): ) validate_snapshot_access(request, snapshot) - files = {f.name: f for f in snapshot.files.all()} + files = {f.name: f for f in snapshot.files.select_related("created_by")} return Response(generate_index(files))