Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Renamed the search argument FromID instead of TorrentID

Cette révision appartient à :
akuma06 2017-05-30 14:12:42 +02:00
Parent 29056496d0
révision b0cf17c77c
4 fichiers modifiés avec 17 ajouts et 11 suppressions

Voir le fichier

@ -157,6 +157,7 @@ func (c *Category) Parse(s string) (ok bool) {
// deprecated for TorrentParam
type SearchParam struct {
TorrentID uint
FromID uint // Search for torrentID > FromID
Order bool // True means acsending
Status Status
Sort SortMode

Voir le fichier

@ -27,6 +27,7 @@ type TorrentParam struct {
Offset uint32
UserID uint32
TorrentID uint32
FromID uint32
NotNull string // csv
Null string // csv
NameLike string // csv
@ -62,9 +63,9 @@ func (p *TorrentParam) FromRequest(r *http.Request) {
}
// FIXME 0 means no userId defined
torrentID, err := strconv.ParseUint(r.URL.Query().Get("torrentID"), 10, 32)
fromID, err := strconv.ParseUint(r.URL.Query().Get("fromID"), 10, 32)
if err != nil {
torrentID = 0
fromID = 0
}
var status Status
@ -94,8 +95,10 @@ func (p *TorrentParam) FromRequest(r *http.Request) {
p.Sort = sortMode
p.Category = category
// FIXME 0 means no TorrentId defined
// Do we even need that ? I do now :p
p.TorrentID = uint32(torrentID)
// Do we even need that ?
p.TorrentID = 0
// Needed to display result after a certain torrentID
p.FromID = uint32(fromID)
}
// ToFilterQuery : Builds a query string with for es query string query defined here
@ -118,8 +121,8 @@ func (p *TorrentParam) ToFilterQuery() string {
query += " status:" + p.Status.ToString()
}
if p.TorrentID != 0 {
query += " id:>" + strconv.FormatInt(int64(p.TorrentID), 10)
if p.FromID != 0 {
query += " id:>" + strconv.FormatInt(int64(p.FromID), 10)
}
return query
}
@ -215,6 +218,7 @@ func (p *TorrentParam) Clone() TorrentParam {
Offset: p.Offset,
UserID: p.UserID,
TorrentID: p.TorrentID,
FromID: p.FromID,
NotNull: p.NotNull,
Null: p.Null,
NameLike: p.NameLike,

Voir le fichier

@ -13,7 +13,7 @@ var Torrents = {
console.log("Start Refresh...")
this.timeout = setTimeout(function() {
var searchArgs = (window.location.search != "") ? window.location.search.substr(1) : ""
searchArgs = (Torrents.LastID > 0) ? "?torrentID="+Torrents.LastID+"&"+searchArgs : "?"+searchArgs
searchArgs = (Torrents.LastID > 0) ? "?fromID="+Torrents.LastID+"&"+searchArgs : "?"+searchArgs
Query.Get(Torrents.SearchURL+searchArgs,
Templates.ApplyItemListRenderer({
templateName: "torrents.item", method: "prepend", element: document.getElementById("torrentListResults")

Voir le fichier

@ -85,6 +85,7 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool, withUser bool, d
totalHits, torrents, err := torrentParam.Find(client)
searchParam := common.SearchParam{
TorrentID: uint(torrentParam.TorrentID),
FromID: uint(torrentParam.FromID),
Order: torrentParam.Order,
Status: torrentParam.Status,
Sort: torrentParam.Sort,
@ -118,8 +119,8 @@ func searchByQueryPostgres(r *http.Request, pagenum int, countAll bool, withUser
search.Query = r.URL.Query().Get("q")
userID, _ := strconv.Atoi(r.URL.Query().Get("userID"))
search.UserID = uint(userID)
torrentID, _ := strconv.Atoi(r.URL.Query().Get("torrentID"))
search.TorrentID = uint(torrentID)
fromID, _ := strconv.Atoi(r.URL.Query().Get("fromID"))
search.FromID = uint(fromID)
switch s := r.URL.Query().Get("s"); s {
case "1":
@ -219,9 +220,9 @@ func searchByQueryPostgres(r *http.Request, pagenum int, countAll bool, withUser
conditions = append(conditions, "uploader = ?")
parameters.Params = append(parameters.Params, search.UserID)
}
if search.TorrentID != 0 {
if search.FromID != 0 {
conditions = append(conditions, "torrent_id > ?")
parameters.Params = append(parameters.Params, search.TorrentID)
parameters.Params = append(parameters.Params, search.FromID)
}
if search.Category.Sub != 0 {
conditions = append(conditions, "sub_category = ?")