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

@ -616,3 +616,14 @@ def list_popular_public_repos(action_count_threshold, time_span, repo_kind='imag
.group_by(RepositoryActionCount.repository, Repository.name, Namespace.username)
.having(fn.Sum(RepositoryActionCount.count) >= action_count_threshold)
.tuples())
def is_empty(namespace_name, repository_name):
""" Returns if the repository referenced by the given namespace and name is empty. If the repo
doesn't exist, returns True.
"""
try:
tag.list_repository_tags(namespace_name, repository_name).limit(1).get()
return False
except RepositoryTag.DoesNotExist:
return True