Skip to content
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

Nobids/improve name search queries #2957

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions handlers/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ func SearchAhead(w http.ResponseWriter, r *http.Request) {
} else {
err = db.ReaderDb.Select(result, `
SELECT validatorindex AS index, pubkeyhex AS pubkey
FROM validators
LEFT JOIN validator_names ON validators.pubkey = validator_names.publickey
WHERE LOWER(validator_names.name) LIKE LOWER($1)
ORDER BY index LIMIT 10`, search+"%")
FROM validators WHERE pubkey IN
(SELECT publickey FROM validator_names WHERE LOWER(validator_names.name) LIKE LOWER($1) LIMIT 10)`, search+"%")
}
case "eth1_addresses":
if utils.IsValidEnsDomain(search) {
Expand Down Expand Up @@ -216,12 +214,9 @@ func SearchAhead(w http.ResponseWriter, r *http.Request) {
} else if thresholdHexLikeRE.MatchString(lowerStrippedSearch) {
err = db.ReaderDb.Select(result, `SELECT validatorindex AS index, pubkeyhex as pubkey FROM validators WHERE pubkeyhex LIKE ($1 || '%')`, lowerStrippedSearch)
} else {
err = db.ReaderDb.Select(result, `
SELECT validatorindex AS index, pubkeyhex AS pubkey
FROM validators
LEFT JOIN validator_names ON validators.pubkey = validator_names.publickey
WHERE LOWER(validator_names.name) LIKE LOWER($1)
ORDER BY index LIMIT 10`, search+"%")
err = db.ReaderDb.Select(result, `SELECT validatorindex AS index, pubkeyhex AS pubkey
FROM validators WHERE pubkey IN
(SELECT publickey FROM validator_names WHERE LOWER(validator_names.name) LIKE LOWER($1) LIMIT 10)`, search+"%")
}
case "validators_by_pubkey":
if !thresholdHexLikeRE.MatchString(lowerStrippedSearch) {
Expand Down
Loading