From 4ada27a3cc33aa6c45013cb88b132f168db3af6e Mon Sep 17 00:00:00 2001 From: ayame-git Date: Wed, 10 May 2017 21:50:27 +0300 Subject: [PATCH] no need for potato fix anymore --- router/modpanel.go | 7 ------- service/report/report.go | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/router/modpanel.go b/router/modpanel.go index 02e16d9a..01102e5d 100644 --- a/router/modpanel.go +++ b/router/modpanel.go @@ -52,10 +52,6 @@ func IndexModPanel(w http.ResponseWriter, r *http.Request) { comments, _ := commentService.GetAllComments(offset, 0, "", "") torrentReports, _, _ := reportService.GetAllTorrentReports(offset, 0) - for i, report := range torrentReports { //shit fix pls fix model - torrentReports[i].Torrent, _ = torrentService.GetTorrentById(fmt.Sprint(report.TorrentID)) - } - fmt.Println(torrentReports) languages.SetTranslationFromRequest(panelIndex, r, "en-us") htv := PanelIndexVbs{torrents, torrentReports, users, comments, NewSearchForm(), currentUser, r.URL} @@ -117,9 +113,6 @@ func TorrentReportListPanel(w http.ResponseWriter, r *http.Request) { offset := 100 torrentReports, nbReports, _ := reportService.GetAllTorrentReports(offset, (pagenum-1)*offset) - for i, report := range torrentReports { //shit fix pls fix the model - torrentReports[i].Torrent, _ = torrentService.GetTorrentById(fmt.Sprint(report.TorrentID)) - } reportJSON := model.TorrentReportsToJSON(torrentReports) languages.SetTranslationFromRequest(panelUserList, r, "en-us") diff --git a/service/report/report.go b/service/report/report.go index 6c55834f..caf2e958 100644 --- a/service/report/report.go +++ b/service/report/report.go @@ -63,7 +63,7 @@ func getTorrentReportsOrderBy(parameters *serviceBase.WhereParams, orderBy strin if limit != 0 || offset != 0 { // if limits provided dbQuery = dbQuery + " LIMIT " + strconv.Itoa(limit) + " OFFSET " + strconv.Itoa(offset) } - err = db.ORM.Raw(dbQuery, params...).Find(&torrentReports).Error + err = db.ORM.Preload("Torrent").Preload("User").Raw(dbQuery, params...).Find(&torrentReports).Error //fixed !!!! return }