Skip to content

Commit

Permalink
BE-636 | Fix search bug (#584) (#587)
Browse files Browse the repository at this point in the history
Fixes a bug when searching pool by pair of tokens for /pools endpoint

(cherry picked from commit 1427db0)

Co-authored-by: Deividas Petraitis <[email protected]>
  • Loading branch information
mergify[bot] and deividaspetraitis authored Dec 4, 2024
1 parent d322a6d commit 5255848
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pools/usecase/pools_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ var filterExactMatchSearch = func(tokenMetadataHolder TokenMetadataHolder, searc
return func(pool sqsdomain.PoolI) bool {
var coinDenoms []string

for _, denom := range pool.GetPoolDenoms() {
for _, denom := range pool.GetSQSPoolModel().PoolDenoms {
token, err := tokenMetadataHolder.GetMetadataByChainDenom(denom)
if err != nil {
continue
Expand All @@ -432,7 +432,7 @@ var filterPartialMatchSearch = func(tokenMetadataHolder TokenMetadataHolder, sea
var poolNameByDenom string
var coinnames []string

for _, denom := range pool.GetPoolDenoms() {
for _, denom := range pool.GetSQSPoolModel().PoolDenoms {
token, err := tokenMetadataHolder.GetMetadataByChainDenom(denom)
if err != nil {
continue
Expand All @@ -442,12 +442,15 @@ var filterPartialMatchSearch = func(tokenMetadataHolder TokenMetadataHolder, sea
}

poolNameByDenom = strings.Join(humanDenoms, "/")
if strings.Contains(strings.ToLower(poolNameByDenom), strings.ToLower(search)) {

search = strings.Replace(strings.ToLower(search), " ", "", -1)

if strings.Contains(strings.ToLower(poolNameByDenom), search) {
return true
}

for _, coinName := range coinnames {
if strings.Contains(strings.ToLower(coinName), strings.ToLower(search)) {
if strings.Contains(strings.ToLower(coinName), search) {
return true
}
}
Expand Down

0 comments on commit 5255848

Please sign in to comment.