Skip to content

Commit

Permalink
Merge branch 'fix/web-search-issue' into web-app
Browse files Browse the repository at this point in the history
  • Loading branch information
wadhia-yash committed Sep 27, 2024
2 parents 6f4968d + 70a0c18 commit afbb12c
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions web/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
throw new Error("Failed to fetch agents");
}
agents = _agents.public_agents.agents;
ownedAgents = _agents.owned_agents.agents;
sharedAgents = _agents.shared_agents.agents;
spotlightAgents = _agents.spotlight_agents.agents;
agents = _agents.public_agents.agents ?? [];
ownedAgents = _agents.owned_agents.agents ?? [];
sharedAgents = _agents.shared_agents.agents ?? [];
spotlightAgents = _agents.spotlight_agents.agents ?? [];
// Combine agents from new API into sections
if (ownedAgents?.length > 0) {
Expand Down Expand Up @@ -137,16 +137,29 @@
};
const search = debounce(async (value: string) => {
searchValue = value.toLowerCase();
filteredAgents = sections["All Agents"].filter((agent) => {
return (
agent.metadata.display_name.toLowerCase().includes(searchValue) ||
agent.author?.name.toLowerCase().includes(searchValue) ||
agent.author?.source_url?.toLowerCase().includes(searchValue)
);
});
appInsights.trackEvent({ name: "Search", properties: { searchValue } }); // Track custom event
}, SEARCH_DEBOUNCE_DELAY);
searchValue = value;
filteredAgents = [];
// Combine agents from all sections to filter
debugger;
const allAgents = [
...ownedAgents,
...sharedAgents,
...spotlightAgents,
...agents
];
filteredAgents = allAgents.filter((agent) => {
return (
agent.metadata.display_name.toLowerCase().includes(searchValue.toLocaleLowerCase()) ||
agent.author?.name?.toLowerCase().includes(searchValue.toLocaleLowerCase()) ||
agent.author?.source_url?.toLowerCase().includes(searchValue.toLocaleLowerCase())
);
});
appInsights.trackEvent({ name: "Search", properties: { searchValue } }); // Track custom event
}, SEARCH_DEBOUNCE_DELAY);
const formatGithubUrl = (url: string) => {
const urlObj = new URL(url);
Expand Down

0 comments on commit afbb12c

Please sign in to comment.