2011-10-29 14:13:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-02-18 10:49:26 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2011-10-29 14:13:14 +00:00
|
|
|
|
2012-03-09 18:27:28 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
2011-10-29 14:13:14 +00:00
|
|
|
|
2013-05-18 21:43:52 +00:00
|
|
|
import app.monkey_patch
|
2011-10-29 14:13:14 +00:00
|
|
|
from ... import models
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
"""
|
|
|
|
rebuild sort/search cache for all items.
|
|
|
|
"""
|
|
|
|
help = 'listen to rabbitmq and execute encoding tasks.'
|
|
|
|
args = ''
|
2016-02-19 18:19:01 +00:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('--all', action='store_true', dest='all',
|
2011-10-29 14:13:14 +00:00
|
|
|
default=False, help='update all items, otherwise oldes N'),
|
2016-02-19 18:19:01 +00:00
|
|
|
parser.add_argument('-n', '--items', action='store', dest='items', type=int,
|
2011-10-29 14:13:14 +00:00
|
|
|
default=30, help='number of items ot update'),
|
|
|
|
|
|
|
|
def handle(self, **options):
|
|
|
|
offset = 0
|
|
|
|
chunk = options['all'] and 100 or options['items']
|
2014-09-19 12:26:46 +00:00
|
|
|
qs = models.Item.objects.exclude(public_id__startswith='0x')
|
2011-10-31 17:50:59 +00:00
|
|
|
count = pos = qs.count()
|
2011-11-02 14:53:21 +00:00
|
|
|
while (options['all'] and offset <= count) or offset < options['items']:
|
2016-02-18 10:49:26 +00:00
|
|
|
print(offset, pos, count)
|
2011-11-02 14:53:21 +00:00
|
|
|
for i in qs.order_by('modified')[:chunk]:
|
2016-02-18 10:49:26 +00:00
|
|
|
print(pos, i.public_id, i.modified)
|
2011-10-29 14:13:14 +00:00
|
|
|
i.update_external()
|
|
|
|
pos -= 1
|
|
|
|
offset += chunk
|