countreports.py 481 B

123456789101112
  1. from django.core.management.base import BaseCommand
  2. from misago.models import Post
  3. from misago.monitor import monitor
  4. class Command(BaseCommand):
  5. """
  6. This command is intended to work as CRON job fired every few minutes/hours to count reported posts
  7. """
  8. help = 'Counts reported posts'
  9. def handle(self, *args, **options):
  10. monitor['reported_posts'] = Post.objects.filter(reported=True).count()
  11. self.stdout.write('Reported posts were recounted.\n')