Merge pull request #793 from gpodder/remove-advertise
[mygpo.git] / mygpo / directory / management / commands / update-toplist.py
blob6753de36d559304e35f41a0486d6b9a3bbb3628e
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(
15 "--silent",
16 action="store_true",
17 dest="silent",
18 default=False,
19 help="Don't show any output",
22 def handle(self, *args, **options):
24 silent = options.get("silent")
26 podcasts = Podcast.objects.all()
27 total = podcasts.count()
29 for n, podcast in enumerate(podcasts):
30 update_podcast_subscribers.delay(podcast.get_id())
32 if not silent:
33 progress(n, total)