Added also a maxage field
Now you can provide ?maxage=nb_days to get the torrents from the last nb_days days
Cette révision appartient à :
Parent
f41f2c3a25
révision
61a0ab0bc3
2 fichiers modifiés avec 17 ajouts et 4 suppressions
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
elastic "gopkg.in/olivere/elastic.v5"
|
||||
|
@ -71,8 +72,13 @@ func (p *TorrentParam) FromRequest(r *http.Request) {
|
|||
var status Status
|
||||
status.Parse(r.URL.Query().Get("s"))
|
||||
|
||||
p.FromDate = r.URL.Query().Get("fromDate")
|
||||
p.ToDate = r.URL.Query().Get("toDate")
|
||||
maxage, err := strconv.Atoi(r.URL.Query().Get("maxage"))
|
||||
if err != nil {
|
||||
p.FromDate = r.URL.Query().Get("fromDate")
|
||||
p.ToDate = r.URL.Query().Get("toDate")
|
||||
} else {
|
||||
p.FromDate = time.Now().AddDate(0, 0, -maxage).Format("2006-01-02")
|
||||
}
|
||||
|
||||
var category Category
|
||||
category.Parse(r.URL.Query().Get("c"))
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
|
@ -123,8 +124,14 @@ func searchByQueryPostgres(r *http.Request, pagenum int, countAll bool, withUser
|
|||
search.UserID = uint(userID)
|
||||
fromID, _ := strconv.Atoi(r.URL.Query().Get("fromID"))
|
||||
search.FromID = uint(fromID)
|
||||
search.FromDate = r.URL.Query().Get("fromDate")
|
||||
search.ToDate = r.URL.Query().Get("toDate")
|
||||
|
||||
maxage, err := strconv.Atoi(r.URL.Query().Get("maxage"))
|
||||
if err != nil {
|
||||
search.FromDate = r.URL.Query().Get("fromDate")
|
||||
search.ToDate = r.URL.Query().Get("toDate")
|
||||
} else {
|
||||
search.FromDate = time.Now().AddDate(0, 0, -maxage).Format("2006-01-02")
|
||||
}
|
||||
|
||||
switch s := r.URL.Query().Get("s"); s {
|
||||
case "1":
|
||||
|
|
Référencer dans un nouveau ticket