Skip to content

Commit 3743ece

Browse files
committed
Use F expresion to get default branches
1 parent b8a408c commit 3743ece

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

codespeed/views.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
import logging
66
import django
77

8+
from django.conf import settings
89
from django.core.urlresolvers import reverse
910
from django.core.exceptions import ValidationError, ObjectDoesNotExist
1011
from django.http import HttpResponse, Http404, HttpResponseBadRequest,\
1112
HttpResponseNotFound
13+
from django.db.models import F
1214
from django.shortcuts import get_object_or_404, render_to_response
1315
from django.views.decorators.http import require_GET, require_POST
1416
from django.views.decorators.csrf import csrf_exempt
1517
from django.template import RequestContext
16-
from django.conf import settings
17-
from .auth import basic_auth_required
1818

19+
from .auth import basic_auth_required
1920
from .models import (Environment, Report, Project, Revision, Result,
2021
Executable, Benchmark, Branch)
2122
from .views_data import (get_default_environment, getbaselineexecutables,
@@ -281,16 +282,11 @@ def gettimelinedata(request):
281282
'baseline': "None",
282283
}
283284
append = False
284-
for proj in Project.objects.filter(track=True):
285-
try:
286-
branch = Branch.objects.get(
287-
project=proj, name=proj.default_branch)
288-
except Branch.DoesNotExist:
289-
continue
290-
291-
# For now, we'll only work with trunk branches
285+
for branch in Branch.objects.filter(
286+
project__track=True, name=F('project__default_branch')):
287+
# For now, we'll only work with default branches
292288
for executable in executables:
293-
if executable.project != proj:
289+
if executable.project != branch.project:
294290
continue
295291

296292
resultquery = Result.objects.filter(

0 commit comments

Comments
 (0)