Merge pull request #3060 from quay/max-results-help-text

Configurable options for search, disable next page & add help text when at max results
This commit is contained in:
Sam Chow 2018-04-25 08:17:35 -07:00 committed by GitHub
commit f89ad30320
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 9 deletions

View file

@ -12,7 +12,7 @@ from auth.permissions import (OrganizationMemberPermission, ReadRepositoryPermis
ReadRepositoryPermission)
from auth.auth_context import get_authenticated_user
from auth import scopes
from app import avatar, authentication
from app import app, avatar, authentication
from flask import abort
from operator import itemgetter
from stringscore import liquidmetal
@ -335,7 +335,8 @@ class ConductSearch(ApiResource):
return {'results': sorted(results, key=itemgetter('score'), reverse=True)}
MAX_PER_PAGE = 10
MAX_PER_PAGE = app.config.get('SEARCH_RESULTS_PER_PAGE', 10)
MAX_RESULT_PAGE_COUNT = app.config.get('SEARCH_MAX_RESULT_PAGE_COUNT', 10)
@resource('/v1/find/repositories')
class ConductRepositorySearch(ApiResource):
@ -347,7 +348,7 @@ class ConductRepositorySearch(ApiResource):
def get(self, parsed_args):
""" Get a list of apps and repositories that match the specified query. """
query = parsed_args['query']
page = min(max(1, parsed_args['page']), 10)
page = min(max(1, parsed_args['page']), MAX_RESULT_PAGE_COUNT)
offset = (page - 1) * MAX_PER_PAGE
limit = offset + MAX_PER_PAGE + 1