Merge pull request #164 from sfan5/pgfix
Search case-sensitivity hotfix
Cette révision appartient à :
révision
591678110f
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")...)
|
data = append(data, []byte("\n")...)
|
||||||
_, err = output.Write(data)
|
_, err = output.Write(data)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/ewhal/nyaa/db"
|
"github.com/ewhal/nyaa/db"
|
||||||
"github.com/ewhal/nyaa/router"
|
"github.com/ewhal/nyaa/router"
|
||||||
"github.com/ewhal/nyaa/util/log"
|
"github.com/ewhal/nyaa/util/log"
|
||||||
|
"github.com/ewhal/nyaa/util/search" // super hacky fix
|
||||||
"github.com/ewhal/nyaa/util/signals"
|
"github.com/ewhal/nyaa/util/signals"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -59,6 +60,7 @@ func main() {
|
||||||
if len(config.TorrentFileStorage) > 0 {
|
if len(config.TorrentFileStorage) > 0 {
|
||||||
os.MkdirAll(config.TorrentFileStorage, 0755)
|
os.MkdirAll(config.TorrentFileStorage, 0755)
|
||||||
}
|
}
|
||||||
|
search.Init(conf.DBType) // super hacky fix
|
||||||
RunServer(conf)
|
RunServer(conf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,17 @@ type SearchParam struct {
|
||||||
Sort string
|
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) {
|
func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents, int) {
|
||||||
maxPerPage, errConv := strconv.Atoi(r.URL.Query().Get("max"))
|
maxPerPage, errConv := strconv.Atoi(r.URL.Query().Get("max"))
|
||||||
if errConv != nil {
|
if errConv != nil {
|
||||||
|
@ -72,7 +83,7 @@ func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents,
|
||||||
}
|
}
|
||||||
searchQuerySplit := strings.Split(search_param.Query, " ")
|
searchQuerySplit := strings.Split(search_param.Query, " ")
|
||||||
for i, _ := range searchQuerySplit {
|
for i, _ := range searchQuerySplit {
|
||||||
conditions = append(conditions, "torrent_name LIKE ?")
|
conditions = append(conditions, "torrent_name " + search_op + " ?")
|
||||||
parameters.Params = append(parameters.Params, "%"+searchQuerySplit[i]+"%")
|
parameters.Params = append(parameters.Params, "%"+searchQuerySplit[i]+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Référencer dans un nouveau ticket