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 0bd586a
Show file tree
Hide file tree
Showing 2 changed files with 9 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
9 changes: 5 additions & 4 deletions handlers/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ 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`,
}), "%"+searchQuery+"%")
fmt.Printf("err: %v\n", err)
if err == nil {
http.Redirect(w, r, "/slots/filtered?f&f.missing=1&f.orphaned=1&f.pname="+searchQuery, http.StatusMovedPermanently)
return
Expand Down

0 comments on commit 0bd586a

Please sign in to comment.