Merge pull request #2688 from coreos-inc/build-badge-query

Remove expensive call in build badge
This commit is contained in:
josephschorr 2017-06-12 15:06:13 -04:00 committed by GitHub
commit b269cb84a3
3 changed files with 20 additions and 5 deletions

View file

@ -620,3 +620,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