Skip to content

Commit

Permalink
fix: best comments, exclude memes, raise limits
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Sep 19, 2023
1 parent b8fb4fd commit 359f2a1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions notifications/management/commands/send_best_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 {}
Expand Down

0 comments on commit 359f2a1

Please sign in to comment.