Skip to content

Commit

Permalink
Merge pull request galaxyproject#19076 from ahmedhamidawan/add_label_…
Browse files Browse the repository at this point in the history
…key_to_tool_search

Add a filter for `labels` (tags) in Tool Search
  • Loading branch information
bgruening authored Oct 30, 2024
2 parents 85b4746 + 28596d3 commit 03307f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/src/components/Panels/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import levenshteinDistance from "@/utils/levenshtein";
const FILTER_KEYS = {
id: ["id", "tool_id"],
panel_section_name: ["section", "panel_section_name"],
labels: ["label", "labels", "tag"],
};
const STRING_REPLACEMENTS: string[] = [" ", "-", "\\(", "\\)", "'", ":", `"`];
const MINIMUM_DL_LENGTH = 5; // for Demerau-Levenshtein distance
Expand Down Expand Up @@ -286,7 +287,14 @@ export function searchToolsByKeys(
if (key === "combined") {
actualValue = `${tool.name.trim()} ${tool.description.trim()}`.toLowerCase();
} else {
actualValue = (tool[key as keyof Tool] as string)?.trim().toLowerCase();
const toolVal = tool[key as keyof Tool];
if (typeof toolVal === "string") {
actualValue = toolVal.trim().toLowerCase();
} else if (Array.isArray(toolVal)) {
actualValue = toolVal.join(" ").trim().toLowerCase();
} else if (typeof toolVal === "number") {
actualValue = toolVal.toString().trim().toLowerCase();
}
}

// get all (space separated) words in actualValue for tool (for DL)
Expand Down

0 comments on commit 03307f6

Please sign in to comment.