From 04c9ef66857fcadffe66bd183799bcebe889385a Mon Sep 17 00:00:00 2001 From: nyaazi Date: Sat, 20 May 2017 15:02:26 +0300 Subject: [PATCH] Redundant query --- nyaa/models.py | 6 +----- nyaa/routes.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/nyaa/models.py b/nyaa/models.py index 1ff6925..d106763 100644 --- a/nyaa/models.py +++ b/nyaa/models.py @@ -422,11 +422,7 @@ class Report(db.Model): @classmethod def not_reviewed(cls, page): - reports = cls.query.filter(cls.status == 0)\ - .join(Torrent, aliased=True).filter(Torrent.flags != 36, Torrent.flags != 2)\ - .order_by(db.asc(cls.id))\ - .paginate(page=page, per_page=20) - # reports = cls.query.filter_by(status=0).paginate(page=page, per_page=20) + reports = cls.query.filter_by(status=0).paginate(page=page, per_page=20) return reports @classmethod diff --git a/nyaa/routes.py b/nyaa/routes.py index 6e37cb5..6fd06e4 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -701,7 +701,7 @@ def view_reports(): report_id = report_action.report.data torrent = models.Torrent.by_id(torrent_id) report = models.Report.by_id(report_id) - + if not torrent or not report or report.status != 0: flask.abort(404) else: