Skip to content

Commit

Permalink
Merge pull request #1478 from opensafely-core/optimise-release-api-qu…
Browse files Browse the repository at this point in the history
…eries

Select extra columns to avoid further queries
  • Loading branch information
ghickman authored Dec 23, 2021
2 parents f59c763 + dff1328 commit bee3aad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jobserver/api/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand All @@ -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))

Expand Down

0 comments on commit bee3aad

Please sign in to comment.