Skip to content

Commit

Permalink
fixed search
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Sep 4, 2023
1 parent e508bb1 commit 2bb3069
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions dbtypes/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type SearchGraffitiResult struct {
Graffiti string `db:"graffiti"`
}

type SearchNameResult struct {
Name string `db:"name"`
}

type SearchAheadEpochsResult []struct {
Epoch uint64 `db:"epoch"`
}
Expand Down
8 changes: 4 additions & 4 deletions handlers/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ func Search(w http.ResponseWriter, r *http.Request) {
}
}

var namesCount uint64
err = db.ReaderDb.Get(namesCount, db.EngineQuery(map[dbtypes.DBEngineType]string{
names := &dbtypes.SearchNameResult{}
err = db.ReaderDb.Get(names, db.EngineQuery(map[dbtypes.DBEngineType]string{
dbtypes.DBEnginePgsql: `
SELECT COUNT(*)
SELECT name
FROM validator_names
WHERE name ILIKE LOWER($1)
LIMIT 1`,
dbtypes.DBEngineSqlite: `
SELECT COUNT(*)
SELECT name
FROM validator_names
WHERE name LIKE LOWER($1)
LIMIT 1`,
Expand Down

0 comments on commit 2bb3069

Please sign in to comment.