countreports.py 521 B

12345678910111213
  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 = Monitor()
  11. monitor['reported_posts'] = Post.objects.filter(reported=True).count()
  12. self.stdout.write('Reported posts were recounted.\n')