From faf33bc2d637e5d6e0d4668eeda7f72b69542d50 Mon Sep 17 00:00:00 2001 From: Deividas Petraitis Date: Wed, 4 Dec 2024 12:11:03 +0200 Subject: [PATCH] BE-636 | Fix search bug Fixes a bug when searching pool by pair of tokens for /pools endpoint --- pools/usecase/pools_usecase.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pools/usecase/pools_usecase.go b/pools/usecase/pools_usecase.go index 69f90871..806cd3d1 100644 --- a/pools/usecase/pools_usecase.go +++ b/pools/usecase/pools_usecase.go @@ -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 @@ -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 @@ -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 } }