Fix absence of pagination on home page
Cette révision appartient à :
Parent
61b34c109d
révision
5bdd160d61
1 fichiers modifiés avec 6 ajouts et 4 suppressions
|
@ -62,20 +62,22 @@ func GetTorrentById(id string) (model.Torrents, error) {
|
|||
func GetTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offset int) ([]model.Torrents, int) {
|
||||
var torrents []model.Torrents
|
||||
var count int
|
||||
conditions := "1" // FIXME
|
||||
var conditionArray []string
|
||||
if strings.HasPrefix(orderBy, "filesize") {
|
||||
// torrents w/ NULL filesize fuck up the sorting on postgres
|
||||
conditions += " AND filesize IS NOT NULL"
|
||||
conditionArray = append(conditionArray, "filesize IS NOT NULL")
|
||||
}
|
||||
|
||||
var params []interface{}
|
||||
if parameters != nil { // if there is where parameters
|
||||
if len(parameters.Conditions) > 0 {
|
||||
conditions += " AND " + parameters.Conditions
|
||||
conditionArray = append(conditionArray, parameters.Conditions)
|
||||
}
|
||||
params = parameters.Params
|
||||
}
|
||||
conditions := strings.Join(conditionArray, " AND ")
|
||||
db.ORM.Model(&torrents).Where(conditions, params...).Count(&count)
|
||||
|
||||
// build custom db query for performance reasons
|
||||
dbQuery := "SELECT * FROM torrents"
|
||||
if conditions != "" {
|
||||
dbQuery = dbQuery + " WHERE " + conditions
|
||||
|
|
Référencer dans un nouveau ticket