-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BE-636 | Fix search bug #584
Conversation
Fixes a bug when searching pool by pair of tokens for /pools endpoint
WalkthroughThe changes in this pull request focus on refining the handling of pool metadata and search functionalities within the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
pools/usecase/pools_usecase.go (1)
448-453
: Consider caching normalized stringsWhile the search logic is correct, we could optimize performance by normalizing strings once at the beginning of the function rather than in each comparison.
Here's a suggested optimization:
var humanDenoms []string var poolNameByDenom string var coinnames []string +var normalizedCoinNames []string for _, denom := range pool.GetSQSPoolModel().PoolDenoms { token, err := tokenMetadataHolder.GetMetadataByChainDenom(denom) if err != nil { continue } coinnames = append(coinnames, token.Name) + normalizedCoinNames = append(normalizedCoinNames, strings.ToLower(token.Name)) humanDenoms = append(humanDenoms, token.HumanDenom) } poolNameByDenom = strings.Join(humanDenoms, "/") +normalizedPoolName := strings.ToLower(poolNameByDenom) search = strings.Replace(strings.ToLower(search), " ", "", -1) -if strings.Contains(strings.ToLower(poolNameByDenom), search) { +if strings.Contains(normalizedPoolName, search) { return true } -for _, coinName := range coinnames { - if strings.Contains(strings.ToLower(coinName), search) { +for _, normalizedName := range normalizedCoinNames { + if strings.Contains(normalizedName, search) { return true } }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
pools/usecase/pools_usecase.go
(3 hunks)
🔇 Additional comments (3)
pools/usecase/pools_usecase.go (3)
408-408
: LGTM: Direct access to pool denominations
The change from GetPoolDenoms()
to direct access via GetSQSPoolModel().PoolDenoms
provides a more reliable way to retrieve pool denominations.
Line range hint 435-445
: LGTM: Consistent pool denomination access
The change maintains consistency with the previous modification and properly constructs the pool name from human denominations.
446-447
: LGTM: Improved search string normalization
The addition of space removal and case normalization makes the search more user-friendly and robust. This change will help users find pools regardless of spacing or case in their search terms.
Quality Gate passedIssues Measures |
Fixes a bug when searching pool by pair of tokens for /pools endpoint (cherry picked from commit 1427db0)
Fixes a bug when searching pool by pair of tokens for /pools endpoint
Summary by CodeRabbit
New Features
Bug Fixes