Merge pull request #3364 from quay/appr-search-fix
Extend appr search to return private repositories
This commit is contained in:
commit
c4f7b28dc6
1 changed files with 34 additions and 17 deletions
|
@ -11,9 +11,27 @@ def list_packages_query(models_ref, namespace=None, media_type=None, search_quer
|
|||
username=None):
|
||||
""" List and filter repository by search query. """
|
||||
Tag = models_ref.Tag
|
||||
fields = [model.repository.SEARCH_FIELDS.name.name]
|
||||
|
||||
if username and not search_query:
|
||||
repositories = model.repository.get_visible_repositories(username,
|
||||
kind_filter='application',
|
||||
include_public=True,
|
||||
namespace=namespace,
|
||||
limit=50)
|
||||
if not repositories:
|
||||
return []
|
||||
|
||||
repo_query = (Repository
|
||||
.select(Repository, Namespace.username)
|
||||
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
|
||||
.where(Repository.id << [repo.rid for repo in repositories]))
|
||||
|
||||
if namespace:
|
||||
repo_query = (repo_query
|
||||
.where(Namespace.username == namespace))
|
||||
else:
|
||||
if search_query is not None:
|
||||
fields = [model.repository.SEARCH_FIELDS.name.name]
|
||||
repositories = model.repository.get_app_search(search_query,
|
||||
username=username,
|
||||
search_fields=fields,
|
||||
|
@ -46,5 +64,4 @@ def list_packages_query(models_ref, namespace=None, media_type=None, search_quer
|
|||
|
||||
tag_query = tag_model.tag_is_alive(tag_query, Tag)
|
||||
query = prefetch(repo_query, tag_query)
|
||||
|
||||
return query
|
||||
|
|
Reference in a new issue