2013-08-01 20:36:42 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-08-01 20:36:42 +02:00
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2013-11-04 17:22:58 +01:00
|
|
|
from zerver.models import Message
|
2013-08-01 20:36:42 +02:00
|
|
|
import datetime
|
|
|
|
import time
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = """Render all historical messages that haven't been rendered yet.
|
|
|
|
|
2015-10-04 18:56:26 +02:00
|
|
|
Usage: python2.7 manage.py render_old_messages"""
|
2013-08-01 20:36:42 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
total_rendered = 0
|
|
|
|
while True:
|
|
|
|
messages = Message.objects.filter(rendered_content_version=None)[0:100]
|
|
|
|
if len(messages) == 0:
|
|
|
|
break
|
|
|
|
for message in messages:
|
2013-09-04 22:44:45 +02:00
|
|
|
message.maybe_render_content(None, save=True)
|
2013-08-01 20:36:42 +02:00
|
|
|
total_rendered += len(messages)
|
2015-11-01 17:11:06 +01:00
|
|
|
print(datetime.datetime.now(), total_rendered)
|
2013-08-01 20:36:42 +02:00
|
|
|
# Put in some sleep so this can run safely on low resource machines
|
|
|
|
time.sleep(0.25)
|