Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit c94d40d

Browse files
authored
badges: fetch branch head and associated commit in same query
1 parent 382f278 commit c94d40d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

graphs/views.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,11 @@ def get_coverage(self):
112112
return None, coverage_range
113113

114114
branch_name = self.kwargs.get("branch") or repo.branch
115-
branch = Branch.objects.filter(
115+
branch_qs = Branch.objects.filter(
116116
name=branch_name, repository_id=repo.repoid
117-
).first()
118-
119-
if branch is None:
120-
log.warning(
121-
"Branch not found", extra=dict(branch_name=branch_name, repo=repo)
122-
)
123-
return None, coverage_range
117+
)
124118
try:
125-
commit = repo.commits.filter(commitid=branch.head).first()
119+
commit = repo.commits.filter(commitid__in=branch_qs.values_list("head", flat=True)).first()
126120
except ObjectDoesNotExist:
127121
# if commit does not exist return None coverage
128122
log.warning("Commit not found", extra=dict(commit=branch.head))

0 commit comments

Comments
 (0)