From 359f2a114a69ec3c5801ac9696342b3da1c71664 Mon Sep 17 00:00:00 2001 From: vas3k Date: Tue, 19 Sep 2023 12:52:08 +0200 Subject: [PATCH] fix: best comments, exclude memes, raise limits --- notifications/management/commands/send_best_comments.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/notifications/management/commands/send_best_comments.py b/notifications/management/commands/send_best_comments.py index f843141d9..b352b9947 100644 --- a/notifications/management/commands/send_best_comments.py +++ b/notifications/management/commands/send_best_comments.py @@ -11,9 +11,9 @@ log = logging.getLogger(__name__) TELEGRAM_CHANNEL_ID = -1001814814883 -TIME_INTERVAL = timedelta(days=3) +TIME_INTERVAL = timedelta(days=4) LIMIT = 30 -MIN_UPVOTES = 15 +MIN_UPVOTES = 20 class Command(BaseCommand): @@ -22,14 +22,11 @@ class Command(BaseCommand): def handle(self, *args, **options): best_comments = Comment.visible_objects().filter( created_at__gte=datetime.utcnow() - TIME_INTERVAL, + post__is_approved_by_moderator=True, upvotes__gte=MIN_UPVOTES, ).order_by("-upvotes")[:LIMIT] for comment in best_comments: - if comment.text.startswith("!"): - # skip images/memes - continue - if not comment.metadata or not comment.metadata.get("in_best_comments"): self.stdout.write(f"Comment {comment.id} +{comment.upvotes}") comment.metadata = comment.metadata or {}