Removing reparsing of pagenum in ES
Cette révision appartient à :
Parent
fb64d13e29
révision
13a15b3b2c
2 fichiers modifiés avec 1 ajouts et 13 suppressions
|
@ -8,7 +8,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
elastic "gopkg.in/olivere/elastic.v5"
|
elastic "gopkg.in/olivere/elastic.v5"
|
||||||
|
|
||||||
"github.com/NyaaPantsu/nyaa/config"
|
"github.com/NyaaPantsu/nyaa/config"
|
||||||
|
@ -45,17 +44,6 @@ func (p *TorrentParam) FromRequest(r *http.Request) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
nameLike := strings.TrimSpace(r.URL.Query().Get("q"))
|
nameLike := strings.TrimSpace(r.URL.Query().Get("q"))
|
||||||
|
|
||||||
page := mux.Vars(r)["page"]
|
|
||||||
if page == "" {
|
|
||||||
page = r.URL.Query().Get("offset")
|
|
||||||
}
|
|
||||||
|
|
||||||
pagenum, err := strconv.ParseUint(page, 10, 32)
|
|
||||||
if err != nil {
|
|
||||||
pagenum = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
max, err := strconv.ParseUint(r.URL.Query().Get("limit"), 10, 32)
|
max, err := strconv.ParseUint(r.URL.Query().Get("limit"), 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
max = uint64(config.Conf.Navigation.TorrentsPerPage)
|
max = uint64(config.Conf.Navigation.TorrentsPerPage)
|
||||||
|
@ -104,7 +92,6 @@ func (p *TorrentParam) FromRequest(r *http.Request) {
|
||||||
language := strings.TrimSpace(r.URL.Query().Get("lang"))
|
language := strings.TrimSpace(r.URL.Query().Get("lang"))
|
||||||
|
|
||||||
p.NameLike = nameLike
|
p.NameLike = nameLike
|
||||||
p.Offset = uint32(pagenum)
|
|
||||||
p.Max = uint32(max)
|
p.Max = uint32(max)
|
||||||
p.UserID = uint32(userID)
|
p.UserID = uint32(userID)
|
||||||
// TODO Use All
|
// TODO Use All
|
||||||
|
|
|
@ -80,6 +80,7 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool, withUser bool, d
|
||||||
if db.ElasticSearchClient != nil {
|
if db.ElasticSearchClient != nil {
|
||||||
var torrentParam common.TorrentParam
|
var torrentParam common.TorrentParam
|
||||||
torrentParam.FromRequest(r)
|
torrentParam.FromRequest(r)
|
||||||
|
torrentParam.Offset = uint32(pagenum)
|
||||||
totalHits, torrents, err := torrentParam.Find(db.ElasticSearchClient)
|
totalHits, torrents, err := torrentParam.Find(db.ElasticSearchClient)
|
||||||
searchParam := common.SearchParam{
|
searchParam := common.SearchParam{
|
||||||
TorrentID: uint(torrentParam.TorrentID),
|
TorrentID: uint(torrentParam.TorrentID),
|
||||||
|
|
Référencer dans un nouveau ticket