Merge pull request #2362 from coreos-inc/fix-none-queries

Fix handling of None queries
This commit is contained in:
josephschorr 2017-02-16 15:32:36 -05:00 committed by GitHub
commit c4837d87b3

View file

@ -287,7 +287,7 @@ def put_repository_auth(namespace_name, repo_name):
@process_auth
@anon_protect
def get_search():
query = request.args.get('q')
query = request.args.get('q') or ''
try:
limit = min(100, max(1, int(request.args.get('n', 25))))
@ -327,8 +327,13 @@ def _conduct_repo_search(username, query, limit=25, page=1):
page = min(page, _MAX_PAGE_COUNT)
only_public = username is None
matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read,
limit=limit*_MAX_PAGE_COUNT)
if query:
matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read,
limit=limit*_MAX_PAGE_COUNT)
else:
matching_repos = []
results = []
for repo in matching_repos[(page - 1) * _MAX_PAGE_COUNT:limit]:
results.append({