parent
1c4d3326c2
commit
7f5b536ddb
5 changed files with 70 additions and 39 deletions
|
@ -2,7 +2,7 @@ import logging
|
|||
import random
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
from peewee import JOIN_LEFT_OUTER, fn
|
||||
from peewee import JOIN_LEFT_OUTER, fn, SQL
|
||||
from cachetools import ttl_cache
|
||||
|
||||
from data.model import (DataModelException, tag, db_transaction, storage, permission,
|
||||
|
@ -245,7 +245,8 @@ def get_when_last_modified(repository_ids):
|
|||
return last_modified_map
|
||||
|
||||
|
||||
def get_visible_repositories(username, namespace=None, include_public=False):
|
||||
def get_visible_repositories(username, namespace=None, include_public=False, start_id=None,
|
||||
limit=None):
|
||||
""" Returns the repositories visible to the given user (if any).
|
||||
"""
|
||||
if not include_public and not username:
|
||||
|
@ -263,7 +264,12 @@ def get_visible_repositories(username, namespace=None, include_public=False):
|
|||
# Note: We only need the permissions table if we will filter based on a user's permissions.
|
||||
query = query.switch(Repository).distinct().join(RepositoryPermission, JOIN_LEFT_OUTER)
|
||||
|
||||
query = _basequery.filter_to_repos_for_user(query, username, namespace, include_public)
|
||||
query = _basequery.filter_to_repos_for_user(query, username, namespace, include_public,
|
||||
start_id=start_id)
|
||||
|
||||
if limit is not None:
|
||||
query = query.limit(limit).order_by(SQL('rid'))
|
||||
|
||||
return query
|
||||
|
||||
|
||||
|
|
Reference in a new issue