Skip to content

Commit b8adf02

Browse files
devin-ai-integration[bot]aditya@dourolabs.xyz
authored andcommitted
fix(developer-hub): prioritize exact ID matches in multi-term search
- Exact ID matches now appear first in search results - Other matches are sorted by ID for consistent ordering - Fixes issue where ID 925 was buried in results when searching 'sol, btc, 925' Co-Authored-By: aditya@dourolabs.xyz <aditya@dourolabs.xyz>
1 parent 06920d7 commit b8adf02

File tree

1 file changed

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

1 file changed

+27
-4
lines changed

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,39 @@ export const PriceFeedIdsProTable = () => {
102102
);
103103
};
104104

105-
// Use Map to deduplicate by pyth_lazer_id
106-
const matchedItems = new Map<number, (typeof items)[number]>();
105+
// Collect matches with priority: exact ID matches first, then others
106+
const exactIdMatches: (typeof items)[number][] = [];
107+
const otherMatches = new Map<number, (typeof items)[number]>();
108+
107109
for (const term of searchTerms) {
110+
const isNumericTerm = /^\d+$/.test(term);
108111
for (const item of items) {
109112
if (termMatchesItem(item, term)) {
110-
matchedItems.set(item.pyth_lazer_id, item);
113+
// Exact ID matches get priority
114+
if (isNumericTerm && String(item.pyth_lazer_id) === term) {
115+
if (
116+
!exactIdMatches.some(
117+
(m) => m.pyth_lazer_id === item.pyth_lazer_id,
118+
)
119+
) {
120+
exactIdMatches.push(item);
121+
}
122+
} else if (
123+
!exactIdMatches.some(
124+
(m) => m.pyth_lazer_id === item.pyth_lazer_id,
125+
)
126+
) {
127+
otherMatches.set(item.pyth_lazer_id, item);
128+
}
111129
}
112130
}
113131
}
114-
return [...matchedItems.values()];
132+
133+
// Return exact ID matches first, then other matches sorted by ID
134+
const otherMatchesArray = [...otherMatches.values()].sort(
135+
(a, b) => a.pyth_lazer_id - b.pyth_lazer_id,
136+
);
137+
return [...exactIdMatches, ...otherMatchesArray];
115138
},
116139
{
117140
defaultSort: "pyth_lazer_id",

0 commit comments

Comments
 (0)