Add FIXMEs
Cette révision appartient à :
Parent
e9a9bd2e88
révision
ee6aea139f
2 fichiers modifiés avec 4 ajouts et 2 suppressions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Référencer dans un nouveau ticket