Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
sfan5 2017-05-10 13:09:23 +02:00
Parent e9a9bd2e88
révision ee6aea139f
2 fichiers modifiés avec 4 ajouts et 2 suppressions

Voir le fichier

@ -42,6 +42,7 @@ type Torrent struct {
}
// Returns the total size of memory recursively allocated for this struct
// FIXME: doesn't go have sizeof or something nicer for this?
func (t Torrent) Size() (s int) {
s += 8 + // ints
2*3 + // time.Time

Voir le fichier

@ -98,7 +98,7 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
torrents []model.Torrent, count int, err error,
) {
var conditionArray []string
conditionArray = append(conditionArray, "deleted_at IS NULL")
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")
@ -112,12 +112,13 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
}
conditions := strings.Join(conditionArray, " AND ")
if countAll {
// FIXME: `deleted_at IS NULL` is duplicate in here because GORM handles this for us
err = db.ORM.Model(&torrents).Where(conditions, params...).Count(&count).Error
if err != nil {
return
}
}
// TODO: Vulnerable to injections. Use query builder.
// TODO: Vulnerable to injections. Use query builder. (is it?)
// build custom db query for performance reasons
dbQuery := "SELECT * FROM torrents"