Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Don't look for old comments on new torrents

Cette révision appartient à :
sfan5 2017-05-08 23:40:54 +02:00
Parent ffc3acfc25
révision 975ce5e6d4
2 fichiers modifiés avec 15 ajouts et 3 suppressions

Voir le fichier

@ -10,6 +10,11 @@ import (
"os"
)
const (
// Highest torrent ID that was copied from nyaa
LastOldTorrentId = 923000
)
type Config struct {
Host string `json: "host"`
Port int `json: "port"`

Voir le fichier

@ -44,10 +44,17 @@ func GetFeeds() []model.Feed {
func GetTorrentById(id string) (model.Torrents, error) {
var torrent model.Torrents
id_int, err := strconv.Atoi(id)
if err != nil {
return torrent, err
}
if db.ORM.Where("torrent_id = ?", id).
Preload("Comments").Preload("OldComments").
Find(&torrent).RecordNotFound() {
tmp := db.ORM.Where("torrent_id = ?", id).Preload("Comments")
if id_int <= config.LastOldTorrentId {
// only preload old comments if they could actually exist
tmp = tmp.Preload("OldComments")
}
if tmp.Find(&torrent).RecordNotFound() {
return torrent, errors.New("Article is not found.")
}
// .Preload("Comments.User") doesn't work