From 251410b20ef5856d49c6f1f6fe9a73be3879ee35 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 23 Oct 2024 12:34:45 -0400 Subject: [PATCH] Better search stuff in Tool Shed 2.0. --- lib/tool_shed/util/shed_index.py | 10 ++++--- .../src/components/RepositoriesGrid.vue | 22 ++++++++++++--- .../pages/RepositoriesByCategory.vue | 11 +++++--- .../components/pages/RepositoriesBySearch.vue | 27 ++++++++++++++++--- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/lib/tool_shed/util/shed_index.py b/lib/tool_shed/util/shed_index.py index ee94d4c1a785..11faf5d9c8c2 100644 --- a/lib/tool_shed/util/shed_index.py +++ b/lib/tool_shed/util/shed_index.py @@ -56,6 +56,8 @@ def build_index(whoosh_index_dir, file_path, hgweb_config_dir, hgweb_repo_prefix execution_timer = ExecutionTimer() with repo_index.searcher() as searcher: for repo in get_repos(sa_session, file_path, hgweb_config_dir, hgweb_repo_prefix, **kwargs): + if repo is None: + continue tools_list = repo.pop("tools_list") repo_id = repo["id"] indexed_document = searcher.document(id=repo_id) @@ -119,9 +121,11 @@ def get_repos(sa_session, file_path, hgweb_config_dir, hgweb_repo_prefix, **kwar full_last_updated = repo.update_time.strftime("%Y-%m-%d %I:%M %p") # Load all changesets of the repo for lineage. - repo_path = os.path.join( - hgweb_config_dir, hgwcm.get_entry(os.path.join(hgweb_repo_prefix, repo.user.username, repo.name)) - ) + try: + entry = hgwcm.get_entry(os.path.join(hgweb_repo_prefix, repo.user.username, repo.name)) + except Exception: + return None + repo_path = os.path.join(hgweb_config_dir, entry) hg_repo = hg.repository(ui.ui(), repo_path.encode("utf-8")) lineage = [] for changeset in hg_repo.changelog: diff --git a/lib/tool_shed/webapp/frontend/src/components/RepositoriesGrid.vue b/lib/tool_shed/webapp/frontend/src/components/RepositoriesGrid.vue index f68dab181613..972677babae9 100644 --- a/lib/tool_shed/webapp/frontend/src/components/RepositoriesGrid.vue +++ b/lib/tool_shed/webapp/frontend/src/components/RepositoriesGrid.vue @@ -14,6 +14,7 @@ interface RepositoriesGridProps { rows: Array noDataLabel?: string debug?: boolean + allowSearch?: boolean } interface ScrollDetails { @@ -29,6 +30,7 @@ const compProps = withDefaults(defineProps(), { debug: false, onScroll: null as OnScroll | null, noDataLabel: "No repositories found", + allowSearch: false, }) const pagination = { rowsPerPage: 0 } @@ -44,7 +46,7 @@ const NAME_COLUMN: QTableColumn = { name: "name", label: "Name", align: "left", - field: "name", + field: "effectiveName", } const columns = computed(() => { @@ -71,10 +73,14 @@ async function onVirtualScroll(details: ScrollDetails) { } } +const search = ref("") + // Adapt the rows with doubleIndex so const adaptedRows = computed(() => compProps.rows.map((r) => { - return { doubleIndex: r.index * 2, ...r } + // create this effective name so we are filtering on this when searching... + const effectiveName = r.owner + " " + r.name + return { doubleIndex: r.index * 2, effectiveName: effectiveName, ...r } }) ) @@ -83,10 +89,10 @@ const adaptedRows = computed(() => hide-header hide-bottom > +