Skip to content

Commit

Permalink
Merge pull request #3400 from opensafely-core/optimise-project-detail…
Browse files Browse the repository at this point in the history
…-queries

Only select needed columns for the first run job query
  • Loading branch information
ghickman authored Aug 15, 2023
2 parents 860fbc9 + 17252fd commit 8f7d03f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions jobserver/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get(self, request, *args, **kwargs):

job = (
Job.objects.filter(job_request__workspace__project=project)
.only("pk", "job_request_id", "created_at", "started_at")
.annotate(first_run=Min(Least("started_at", "created_at")))
.order_by("first_run")
.first()
Expand Down

0 comments on commit 8f7d03f

Please sign in to comment.