update queued

This commit is contained in:
j 2015-03-05 16:36:53 +05:30
parent 0c9271895f
commit c2c6e331d7

View file

@ -17,6 +17,7 @@ import text.models
def cron(**kwargs): def cron(**kwargs):
update_double_imdb() update_double_imdb()
outofcopyright() outofcopyright()
update_queued()
update_keywords() update_keywords()
def outofcopyright(): def outofcopyright():
@ -37,7 +38,6 @@ def update_double_imdb():
transaction.commit_unless_managed() transaction.commit_unless_managed()
def update_keywords(): def update_keywords():
t = text.models.Text.get('j:Keywords') t = text.models.Text.get('j:Keywords')
keywords = Counter([a['value'] keywords = Counter([a['value']
@ -50,3 +50,18 @@ def update_keywords():
t.text = '\n'.join(data) t.text = '\n'.join(data)
t.save() t.save()
def update_queued():
import archive.models
l = itemlist.models.List.get('j:Queued')
for f in archive.models.File.objects.filter(queued=True).exclude(id__in=l.items.all()):
l.add(f.item)
for i in l.items.all():
if not i.files.filter(queued=True).exists():
l.remove(i)
l = itemlist.models.List.get('j:Encoding')
for f in archive.models.File.objects.filter(encoding=True).exclude(id__in=l.items.all()):
l.add(f.item)
for i in l.items.all():
if not i.files.filter(encoding=True).exists():
l.remove(i)
transaction.commit_unless_managed()