Switch V2 pagination back to using IDs, which should be much faster and easier on the DB
Also adds a test for the tags endpoint
This commit is contained in:
parent
b8b2c75822
commit
3161b60522
7 changed files with 105 additions and 31 deletions
|
@ -13,7 +13,7 @@ from endpoints.v2.models_pre_oci import data_model as model
|
|||
@process_registry_jwt_auth()
|
||||
@anon_protect
|
||||
@paginate()
|
||||
def catalog_search(limit, offset, pagination_callback):
|
||||
def catalog_search(start_id, limit, pagination_callback):
|
||||
include_public = bool(features.PUBLIC_CATALOG)
|
||||
if not include_public and not get_authenticated_user():
|
||||
return jsonify({'repositories': []})
|
||||
|
@ -22,11 +22,12 @@ def catalog_search(limit, offset, pagination_callback):
|
|||
if username and not get_authenticated_user().enabled:
|
||||
return jsonify({'repositories': []})
|
||||
|
||||
visible_repositories = model.get_visible_repositories(username, limit + 1, offset,
|
||||
visible_repositories = model.get_visible_repositories(username, start_id, limit,
|
||||
include_public=include_public)
|
||||
response = jsonify({
|
||||
'repositories': ['%s/%s' % (repo.namespace_name, repo.name)
|
||||
for repo in visible_repositories][0:limit],})
|
||||
for repo in visible_repositories][0:limit],
|
||||
})
|
||||
|
||||
pagination_callback(len(visible_repositories), response)
|
||||
pagination_callback(visible_repositories, response)
|
||||
return response
|
||||
|
|
Reference in a new issue