podcast parsing as a celery task
[mygpo.git] / mygpo / directory / management / commands / update-toplist.py
blobe73496a5e14d81b3de366009516ae7afb62a9668
1 from optparse import make_option
3 from django.core.management.base import BaseCommand
5 from mygpo.utils import progress
6 from mygpo.db.couchdb.podcast import podcast_count, all_podcasts
7 from mygpo.directory.tasks import update_podcast_subscribers
10 class Command(BaseCommand):
11 """ For each podcast a task is scheduled to update its subscriber count """
13 option_list = BaseCommand.option_list + (
14 make_option('--silent', action='store_true', dest='silent',
15 default=False, help="Don't show any output"),
18 def handle(self, *args, **options):
20 silent = options.get('silent')
22 podcasts = all_podcasts()
23 total = podcast_count()
25 for n, podcast in enumerate(podcasts):
26 update_podcast_subscribers.delay(podcast.get_id())
28 if not silent:
29 progress(n, total)