syncdeltas.py 548 B

123456789101112
  1. from django.core.management.base import BaseCommand
  2. from django.db.models import F
  3. from misago.models import Forum
  4. class Command(BaseCommand):
  5. """
  6. This command is intended to work as CRON job fired every few hours to update threads/posts/clicks history on forum
  7. """
  8. help = 'Clears users sessions'
  9. def handle(self, *args, **options):
  10. Forum.objects.all().update(threads_delta=F('threads'), posts_delta=F('posts'), redirects_delta=F('redirects'))
  11. self.stdout.write('Forums deltas have been synced.\n')