Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clean_kombu_messages.py 564B

12345678910111213141516171819202122
  1. from __future__ import absolute_import
  2. from django.core.management.base import BaseCommand
  3. def pluralize(desc, value):
  4. if value > 1:
  5. return desc + 's'
  6. return desc
  7. class Command(BaseCommand):
  8. requires_model_validation = True
  9. def handle(self, *args, **options):
  10. from kombu.transport.django.models import Message
  11. count = Message.objects.filter(visible=False).count()
  12. print('Removing {0} invisible {1} from database... '.format(
  13. count, pluralize('message', count)))
  14. Message.objects.cleanup()