Skip to content

Commit 160d6a5

Browse files
devin-ai-integration[bot]aditya@dourolabs.xyz
authored andcommitted
feat(developer-hub): add multi-feed search functionality to Lazer price feed IDs
Users can now search for multiple feeds simultaneously by entering comma or space-separated search terms. For example: - 'BTC ETH' shows feeds matching either BTC or ETH - 'BTC, ETH, SOL' shows feeds matching any of the three terms The search uses OR logic - a feed is shown if it matches ANY of the search terms. Co-Authored-By: aditya@dourolabs.xyz <aditya@dourolabs.xyz>
1 parent 77ccbcf commit 160d6a5

File tree

1 file changed

+30
-4
lines changed
  • apps/developer-hub/src/components/PriceFeedIdsProTable

1 file changed

+30
-4
lines changed

apps/developer-hub/src/components/PriceFeedIdsProTable/index.tsx

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,35 @@ export const PriceFeedIdsProTable = () => {
6161
if (!searchString) {
6262
return items;
6363
}
64-
return matchSorter(items, searchString, {
65-
keys: ["pyth_lazer_id", "symbol", "name", "description"],
66-
});
64+
// Split by commas or spaces to support multiple search terms
65+
const searchTerms = searchString
66+
.split(/[,\s]+/)
67+
.map((term) => term.trim().toLowerCase())
68+
.filter((term) => term.length > 0);
69+
70+
if (searchTerms.length === 0) {
71+
return items;
72+
}
73+
74+
// For single term, use matchSorter directly for better ranking
75+
const firstTerm = searchTerms[0];
76+
if (searchTerms.length === 1 && firstTerm !== undefined) {
77+
return matchSorter(items, firstTerm, {
78+
keys: ["pyth_lazer_id", "symbol", "name", "description"],
79+
});
80+
}
81+
82+
// For multiple terms, return items matching ANY term (OR logic)
83+
const matchedItems = new Set<(typeof items)[number]>();
84+
for (const term of searchTerms) {
85+
const matches = matchSorter(items, term, {
86+
keys: ["pyth_lazer_id", "symbol", "name", "description"],
87+
});
88+
for (const match of matches) {
89+
matchedItems.add(match);
90+
}
91+
}
92+
return [...matchedItems];
6793
},
6894
{
6995
defaultSort: "pyth_lazer_id",
@@ -95,7 +121,7 @@ export const PriceFeedIdsProTable = () => {
95121
<>
96122
<SearchInput
97123
label="Search price feeds"
98-
placeholder="Search by symbol, name, or Pyth Pro ID"
124+
placeholder="Search by symbol, name, or ID (comma/space separated)"
99125
value={search}
100126
onChange={updateSearch}
101127
className={styles.searchInput ?? ""}

0 commit comments

Comments
 (0)