Really fix the hack (for now) on public repo pagination
This commit is contained in:
parent
cbc9ec7848
commit
4f5b4e63f2
2 changed files with 7 additions and 11 deletions
|
@ -159,20 +159,16 @@ class RepositoryList(ApiResource):
|
|||
|
||||
repo_query = model.repository.get_user_starred_repositories(user)
|
||||
else:
|
||||
# TEMP: Only supply the filter username if a specific namespace is requested. If the request
|
||||
# is for all public repositories, simply return them. This ensures that we don't paginate
|
||||
# over a union query.
|
||||
# TODO(jschorr): Fix pagination for union queries so we can remove this restriction!
|
||||
filter_username = (username if not parsed_args['namespace'] and not parsed_args['starred']
|
||||
else None)
|
||||
|
||||
repo_query = model.repository.get_visible_repositories(username=filter_username,
|
||||
repo_query = model.repository.get_visible_repositories(username=username,
|
||||
include_public=parsed_args['public'],
|
||||
namespace=parsed_args['namespace'])
|
||||
|
||||
# Note: We only limit repositories when there isn't a namespace or starred filter, as they
|
||||
# result in far smaller queries.
|
||||
if not parsed_args['namespace'] and not parsed_args['starred']:
|
||||
# TODO: Fix pagination to support union queries and then remove this hack.
|
||||
repo_query = model.repository.get_visible_repositories(None,
|
||||
include_public=parsed_args['public'])
|
||||
repos, next_page_token = model.modelutil.paginate(repo_query, RepositoryTable,
|
||||
page_token=page_token, limit=REPOS_PER_PAGE,
|
||||
id_alias='rid')
|
||||
|
|
|
@ -1447,9 +1447,9 @@ class TestCreateRepo(ApiTestCase):
|
|||
class TestListRepos(ApiTestCase):
|
||||
def test_listrepos_asguest(self):
|
||||
# Queries: Base + the list query
|
||||
with assert_query_count(BASE_QUERY_COUNT + 1):
|
||||
json = self.getJsonResponse(RepositoryList, params=dict(public=True))
|
||||
|
||||
# TODO: uncomment once fixed
|
||||
#with assert_query_count(BASE_QUERY_COUNT + 1):
|
||||
json = self.getJsonResponse(RepositoryList, params=dict(public=True))
|
||||
self.assertEquals(len(json['repositories']), 1)
|
||||
|
||||
def test_listrepos_asguest_withpages(self):
|
||||
|
|
Reference in a new issue