Merge branch 'master' of ssh://bitbucket.org/yackob03/quay

This commit is contained in:
yackob03 2014-01-13 16:33:04 -05:00
commit 97d179cafb
4 changed files with 84 additions and 6 deletions

View file

@ -498,13 +498,23 @@ def get_user_teams_within_org(username, organization):
User.username == username)
def get_visible_repositories(username=None, include_public=True, limit=None,
def get_visible_repository_count(username=None, include_public=True, sort=False, namespace=None):
return get_visible_repository_internal(username=username, include_public=include_public,
sort=sort, namespace=namespace, get_count=True)
def get_visible_repositories(username=None, include_public=True, page=None, limit=None,
sort=False, namespace=None):
return get_visible_repository_internal(username=username, include_public=include_public, page=page,
limit=limit, sort=sort, namespace=namespace, get_count=False)
def get_visible_repository_internal(username=None, include_public=True, limit=None, page=None,
sort=False, namespace=None, get_count=False):
if not username and not include_public:
return []
query = (Repository
.select(Repository, Visibility)
.select() # Note: We need to leave this blank for the get_count case. Otherwise, MySQL/RDS complains.
.distinct()
.join(Visibility)
.switch(Repository)
@ -552,10 +562,19 @@ def get_visible_repositories(username=None, include_public=True, limit=None,
else:
where_clause = new_clause
if limit:
if sort:
query = query.order_by(Repository.description.desc())
if page:
query = query.paginate(page, limit)
elif limit:
query = query.limit(limit)
return query.where(where_clause)
where = query.where(where_clause)
if get_count:
return where.count()
else:
return where
def get_matching_repositories(repo_term, username=None):