add manage command to rebuild cache, only update cache after updating sort values
This commit is contained in:
parent
e37657436b
commit
0cdafdef9b
6 changed files with 41 additions and 6 deletions
0
pandora/item/management/__init__.py
Normal file
0
pandora/item/management/__init__.py
Normal file
0
pandora/item/management/commands/__init__.py
Normal file
0
pandora/item/management/commands/__init__.py
Normal file
29
pandora/item/management/commands/rebuildcache.py
Normal file
29
pandora/item/management/commands/rebuildcache.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
import os
|
||||
from os.path import join, dirname, basename, splitext, exists
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.conf import settings
|
||||
|
||||
from ... import models
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
rebuild sort/search cache for all items.
|
||||
"""
|
||||
help = 'listen to rabbitmq and execute encoding tasks.'
|
||||
args = ''
|
||||
|
||||
def handle(self, **options):
|
||||
offset = 0
|
||||
chunk = 100
|
||||
pos = models.Item.objects.count()
|
||||
while offset <= models.Item.objects.count():
|
||||
for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]:
|
||||
print pos, i.itemId
|
||||
i.save()
|
||||
pos -= 1
|
||||
offset += chunk
|
||||
Loading…
Add table
Add a link
Reference in a new issue