[odrs-web] Delete all reviews with taboo, it's impossible to moderate them all



commit 3c895a8bd9aab75afe6097aca17ddc33b55afaf0
Author: Richard Hughes <richard hughsie com>
Date:   Thu Mar 17 13:59:46 2022 +0000

    Delete all reviews with taboo, it's impossible to moderate them all

 app_data/cron.py | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/app_data/cron.py b/app_data/cron.py
index cc035cf..efebeaf 100755
--- a/app_data/cron.py
+++ b/app_data/cron.py
@@ -75,17 +75,25 @@ def _fsck_components():
 
 def _auto_delete(days=31):
 
+    # delete all reviews with taboo, otherwise the moderatorators get overwhelmed
+    for review in (
+        db.session.query(Review)
+        .filter(Review.reported == 5)
+        .order_by(Review.date_created.asc())
+        .limit(1000)
+    ):
+        db.session.delete(review)
+    db.session.commit()
+
+    # clean up all old deleted reviews
     since = datetime.datetime.now() - datetime.timedelta(days=days)
-    reviews = db.session.query(Review).\
-                    filter(Review.date_deleted != None).\
-                    filter(Review.date_deleted < since).\
-                    order_by(Review.date_created.asc()).\
-                    all()
-    if len(reviews) > 1000:
-        print('too many reviews to delete: {}'.format(len(reviews)))
-        return
-    print('Deleting {} reviews...'.format(len(reviews)))
-    for review in reviews:
+    for review in (
+        db.session.query(Review)
+        .filter(Review.date_deleted != None)
+        .filter(Review.date_deleted < since)
+        .order_by(Review.date_created.asc())
+        .limit(1000)
+    ):
         db.session.delete(review)
     db.session.commit()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]