Skip to content

Commit

Permalink
fix(gui): If two asbs have the same relevancy score, sort by price
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybaron committed Nov 19, 2024
1 parent 288a13e commit c5958c4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src-gui/src/utils/sortUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ export function sortProviderList(list: ExtendedProviderStatus[]) {
if (isProviderOutdated(firstEl) && !isProviderOutdated(secondEl)) return 1;
if (!isProviderOutdated(firstEl) && isProviderOutdated(secondEl)) return -1;

// If neither of them have a relevancy score, sort by price
if (firstEl.relevancy == null && secondEl.relevancy == null) {
// If neither of them have a relevancy score or they are the same, sort by price
if (firstEl.relevancy == secondEl.relevancy) {
return firstEl.price - secondEl.price;
}

// If only on of the two don't have a relevancy score, prioritize the one that does
// If only one of the two doesn't have a relevancy score, prioritize the one that does
if (firstEl.relevancy == null) return 1;
if (secondEl.relevancy == null) return -1;

// Otherwise, sort by relevancy score
if (firstEl.relevancy > secondEl.relevancy) {
return -1;
}
return 1;
return secondEl.relevancy - firstEl.relevancy;
})
// Remove duplicate providers
.filter((provider, index, self) =>
Expand Down

0 comments on commit c5958c4

Please sign in to comment.