Make sorting by date date work nicely
Cette révision appartient à :
Parent
937c9752af
révision
b930997c68
2 fichiers modifiés avec 6 ajouts et 11 suppressions
|
@ -112,10 +112,6 @@ func getTorrentsOrderBy(parameters *serviceBase.WhereParams, orderBy string, lim
|
|||
) {
|
||||
var conditionArray []string
|
||||
conditionArray = append(conditionArray, "deleted_at IS NULL")
|
||||
if strings.HasPrefix(orderBy, "filesize") {
|
||||
// torrents w/ NULL filesize fuck up the sorting on Postgres
|
||||
conditionArray = append(conditionArray, "filesize IS NOT NULL")
|
||||
}
|
||||
var params []interface{}
|
||||
if parameters != nil { // if there is where parameters
|
||||
if len(parameters.Conditions) > 0 {
|
||||
|
|
|
@ -106,6 +106,7 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool) (
|
|||
case "2":
|
||||
search.Sort = common.Date
|
||||
orderBy += "date"
|
||||
search.NotNull = "date IS NOT NULL"
|
||||
break
|
||||
case "3":
|
||||
search.Sort = common.Downloads
|
||||
|
@ -114,21 +115,23 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool) (
|
|||
case "4":
|
||||
search.Sort = common.Size
|
||||
orderBy += "filesize"
|
||||
// avoid sorting completely breaking on postgres
|
||||
search.NotNull = "filesize IS NOT NULL"
|
||||
break
|
||||
case "5":
|
||||
search.Sort = common.Seeders
|
||||
orderBy += "seeders"
|
||||
search.NotNull += "seeders IS NOT NULL "
|
||||
search.NotNull = "seeders IS NOT NULL"
|
||||
break
|
||||
case "6":
|
||||
search.Sort = common.Leechers
|
||||
orderBy += "leechers"
|
||||
search.NotNull += "leechers IS NOT NULL "
|
||||
search.NotNull = "leechers IS NOT NULL"
|
||||
break
|
||||
case "7":
|
||||
search.Sort = common.Completed
|
||||
orderBy += "completed"
|
||||
search.NotNull += "completed IS NOT NULL "
|
||||
search.NotNull = "completed IS NOT NULL"
|
||||
break
|
||||
default:
|
||||
search.Sort = common.ID
|
||||
|
@ -173,10 +176,6 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool) (
|
|||
conditions = append(conditions, search.NotNull)
|
||||
}
|
||||
|
||||
if len(search.NotNull) > 0 {
|
||||
conditions = append(conditions, search.NotNull)
|
||||
}
|
||||
|
||||
searchQuerySplit := strings.Fields(search.Query)
|
||||
for _, word := range searchQuerySplit {
|
||||
firstRune, _ := utf8.DecodeRuneInString(word)
|
||||
|
|
Référencer dans un nouveau ticket