Add page support to the public repo list
This commit is contained in:
parent
f8b4057b26
commit
58b3ce2647
4 changed files with 82 additions and 5 deletions
|
@ -498,8 +498,18 @@ 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 []
|
||||
|
||||
|
@ -552,10 +562,20 @@ def get_visible_repositories(username=None, include_public=True, limit=None,
|
|||
else:
|
||||
where_clause = new_clause
|
||||
|
||||
if limit:
|
||||
if sort:
|
||||
# TODO: Add the sorting clause here.
|
||||
pass
|
||||
|
||||
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):
|
||||
|
|
Reference in a new issue