Fix pagination of repositories

Fixes #1725
This commit is contained in:
Joseph Schorr 2016-08-15 16:11:45 -04:00
parent 1c4d3326c2
commit 7f5b536ddb
5 changed files with 70 additions and 39 deletions

View file

@ -34,10 +34,15 @@ def get_public_repo_visibility():
return Visibility.get(name='public')
def filter_to_repos_for_user(query, username=None, namespace=None, include_public=True):
def filter_to_repos_for_user(query, username=None, namespace=None, include_public=True,
start_id=None):
if not include_public and not username:
return Repository.select().where(Repository.id == '-1')
# Add the start ID if necessary.
if start_id is not None:
query = query.where(Repository.id >= start_id)
# Build a set of queries that, when unioned together, return the full set of visible repositories
# for the filters specified.
queries = []