Remove expensive call in build badge

We don't need to list all the tags to determine if any exist, and showing the repo is ready when it is empty is probably correct behavior anyway
This commit is contained in:
Joseph Schorr 2017-06-07 15:05:29 -04:00
parent f0dd2e348b
commit a949a44cb2
3 changed files with 20 additions and 5 deletions

View file

@ -479,11 +479,8 @@ def build_status_badge(namespace_name, repo_name):
if not repo or token != repo.badge_token:
abort(404)
# Lookup the tags for the repository.
tags = model.tag.list_repository_tags(namespace_name, repo_name)
is_empty = len(list(tags)) == 0
is_empty = model.repository.is_empty(namespace_name, repo_name)
recent_build = model.build.get_recent_repository_build(namespace_name, repo_name)
if not is_empty and (not recent_build or recent_build.phase == 'complete'):
status_name = 'ready'
elif recent_build and recent_build.phase == 'error':