From c2c6e331d7b86ddb54ecde90dd1f5bdf377cefd2 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 5 Mar 2015 16:36:53 +0530 Subject: [PATCH] update queued --- tasks.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 6fce2bf..186d918 100644 --- a/tasks.py +++ b/tasks.py @@ -17,6 +17,7 @@ import text.models def cron(**kwargs): update_double_imdb() outofcopyright() + update_queued() update_keywords() def outofcopyright(): @@ -37,7 +38,6 @@ def update_double_imdb(): transaction.commit_unless_managed() - def update_keywords(): t = text.models.Text.get('j:Keywords') keywords = Counter([a['value'] @@ -50,3 +50,18 @@ def update_keywords(): t.text = '\n'.join(data) 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()