Implement new search UI
We now have both autocomplete-based searching for quick results, as well as a full search page for a full listing of results
This commit is contained in:
parent
8b148bf1d4
commit
e9ffe0e27b
23 changed files with 649 additions and 393 deletions
|
@ -318,6 +318,9 @@ def repository_is_starred(user, repository):
|
|||
|
||||
|
||||
def get_when_last_modified(repository_ids):
|
||||
""" Returns a map from repository ID to the last modified time (in s) for each repository in the
|
||||
given repository IDs list.
|
||||
"""
|
||||
if not repository_ids:
|
||||
return {}
|
||||
|
||||
|
@ -334,6 +337,26 @@ def get_when_last_modified(repository_ids):
|
|||
return last_modified_map
|
||||
|
||||
|
||||
def get_stars(repository_ids):
|
||||
""" Returns a map from repository ID to the number of stars for each repository in the
|
||||
given repository IDs list.
|
||||
"""
|
||||
if not repository_ids:
|
||||
return {}
|
||||
|
||||
tuples = (Star
|
||||
.select(Star.repository, fn.Count(Star.id))
|
||||
.where(Star.repository << repository_ids)
|
||||
.group_by(Star.repository)
|
||||
.tuples())
|
||||
|
||||
star_map = {}
|
||||
for record in tuples:
|
||||
star_map[record[0]] = record[1]
|
||||
|
||||
return star_map
|
||||
|
||||
|
||||
def get_visible_repositories(username, namespace=None, kind_filter='image', include_public=False,
|
||||
start_id=None, limit=None):
|
||||
""" Returns the repositories visible to the given user (if any).
|
||||
|
@ -471,10 +494,12 @@ def _get_sorted_matching_repositories(lookup_value, repo_kind='image', include_p
|
|||
query = (Repository
|
||||
.select(Repository, Namespace)
|
||||
.join(Namespace, on=(Namespace.id == Repository.namespace_user))
|
||||
.where(clause,
|
||||
Repository.kind == Repository.kind.get_id(repo_kind))
|
||||
.where(clause)
|
||||
.group_by(Repository.id, Namespace.id))
|
||||
|
||||
if repo_kind is not None:
|
||||
query = query.where(Repository.kind == Repository.kind.get_id(repo_kind))
|
||||
|
||||
if not include_private:
|
||||
query = query.where(Repository.visibility == _basequery.get_public_repo_visibility())
|
||||
|
||||
|
|
Reference in a new issue