зеркало из https://github.com/mozilla/treeherder.git
Bug 1304148 - Simplify the code in the job-log-url endpoint
Reduce the number of SQL queries from 3 to just 1
This commit is contained in:
Родитель
8fdf0f36d2
Коммит
3b3e55ab66
|
@ -31,8 +31,6 @@ class JobLogUrlViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
GET method implementation for list view
|
||||
job_id -- Mandatory filter indicating which job these log belongs to.
|
||||
"""
|
||||
repository = Repository.objects.get(name=project)
|
||||
|
||||
job_id = request.query_params.get('job_id')
|
||||
if not job_id:
|
||||
raise ParseError(
|
||||
|
@ -42,7 +40,7 @@ class JobLogUrlViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
except ValueError:
|
||||
raise ParseError(detail="The job_id parameter must be an integer")
|
||||
|
||||
jobs = Job.objects.filter(repository=repository,
|
||||
project_specific_id=job_id)
|
||||
return Response([self._log_as_dict(log) for log in
|
||||
JobLog.objects.filter(job__in=jobs)])
|
||||
logs = JobLog.objects.filter(job__repository__name=project,
|
||||
job__project_specific_id=job_id)
|
||||
|
||||
return Response([self._log_as_dict(log) for log in logs])
|
||||
|
|
Загрузка…
Ссылка в новой задаче