Search case-sensitivity hotfix
Cette révision appartient à :
Parent
b1ac8d82f7
révision
ae89508f23
3 fichiers modifiés avec 15 ajouts et 2 suppressions
|
@ -102,4 +102,4 @@ func (config *Config) Pretty(output io.Writer) error {
|
|||
data = append(data, []byte("\n")...)
|
||||
_, err = output.Write(data)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/ewhal/nyaa/db"
|
||||
"github.com/ewhal/nyaa/router"
|
||||
"github.com/ewhal/nyaa/util/log"
|
||||
"github.com/ewhal/nyaa/util/search" // super hacky fix
|
||||
"github.com/ewhal/nyaa/util/signals"
|
||||
|
||||
"net/http"
|
||||
|
@ -59,6 +60,7 @@ func main() {
|
|||
if len(config.TorrentFileStorage) > 0 {
|
||||
os.MkdirAll(config.TorrentFileStorage, 0755)
|
||||
}
|
||||
search.Init(conf.DBType) // super hacky fix
|
||||
RunServer(conf)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,17 @@ type SearchParam struct {
|
|||
Sort string
|
||||
}
|
||||
|
||||
|
||||
// super hacky fix:
|
||||
var search_op string
|
||||
func Init(backend string) {
|
||||
if backend == "postgres" {
|
||||
search_op = "ILIKE"
|
||||
} else {
|
||||
search_op = "LIKE"
|
||||
}
|
||||
}
|
||||
|
||||
func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents, int) {
|
||||
maxPerPage, errConv := strconv.Atoi(r.URL.Query().Get("max"))
|
||||
if errConv != nil {
|
||||
|
@ -72,7 +83,7 @@ func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents,
|
|||
}
|
||||
searchQuerySplit := strings.Split(search_param.Query, " ")
|
||||
for i, _ := range searchQuerySplit {
|
||||
conditions = append(conditions, "torrent_name LIKE ?")
|
||||
conditions = append(conditions, "torrent_name " + search_op + " ?")
|
||||
parameters.Params = append(parameters.Params, "%"+searchQuerySplit[i]+"%")
|
||||
}
|
||||
|
||||
|
|
Référencer dans un nouveau ticket