Update implementation of management commands
[mygpo.git] / mygpo / directory / management / commands / update-toplist.py
blobbe486669fe055b51dafeb791c6e0864b364d0808
1 from optparse import make_option
3 from django.core.management.base import BaseCommand
5 from mygpo.podcasts.models import Podcast
6 from mygpo.utils import progress
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 def add_arguments(self, parser):
14 parser.add_argument('--silent', action='store_true', dest='silent',
15 default=False, help="Don't show any output"),
17 def handle(self, *args, **options):
19 silent = options.get('silent')
21 podcasts = Podcast.objects.all()
22 total = podcasts.count_fast()
24 for n, podcast in enumerate(podcasts):
25 update_podcast_subscribers.delay(podcast.get_id())
27 if not silent:
28 progress(n, total)