From 8640344193033e005ae4e2b703c2c4e497fcf82c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Mon, 9 Jun 2014 16:23:12 +0200 Subject: [PATCH] fetch "all_podcasts" from PostgreSQL --- .../management/commands/update-related-podcasts.py | 4 ++-- mygpo/db/couchdb/podcast.py | 24 ---------------------- .../management/commands/update-toplist.py | 5 ++--- 3 files changed, 4 insertions(+), 29 deletions(-) diff --git a/mygpo/data/management/commands/update-related-podcasts.py b/mygpo/data/management/commands/update-related-podcasts.py index c8cb4f03..a6b51664 100644 --- a/mygpo/data/management/commands/update-related-podcasts.py +++ b/mygpo/data/management/commands/update-related-podcasts.py @@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand from mygpo.podcasts.models import Podcast from mygpo.data.podcast import calc_similar_podcasts from mygpo.utils import progress -from mygpo.db.couchdb.podcast import all_podcasts, update_related_podcasts +from mygpo.db.couchdb.podcast import update_related_podcasts class Command(BaseCommand): @@ -22,7 +22,7 @@ class Command(BaseCommand): max_related = options.get('max') - podcasts = all_podcasts() + podcasts = Podcast.objects.all() total = Podcast.objects.count() for (n, podcast) in enumerate(podcasts): diff --git a/mygpo/db/couchdb/podcast.py b/mygpo/db/couchdb/podcast.py index 9a02445e..92946603 100644 --- a/mygpo/db/couchdb/podcast.py +++ b/mygpo/db/couchdb/podcast.py @@ -351,30 +351,6 @@ def podcasts_by_next_update(limit=100): return list(res) - - -def all_podcasts(): - from mygpo.db.couchdb.utils import multi_request_view - res = multi_request_view(Podcast,'podcasts/by_id', - wrap = False, - include_docs = True, - stale = 'update_after', - ) - - # TODO: this method is only used for maintenance purposes; should we - # really send 'incomplete_obj' signals here? - - for r in res: - obj = r['doc'] - if obj['doc_type'] == 'Podcast': - yield Podcast.wrap(obj) - else: - pid = r[u'key'] - pg = PodcastGroup.wrap(obj) - podcast = pg.get_podcast_by_id(pid) - yield podcast - - def podcasts_to_dict(ids, use_cache=False): if ids is None: diff --git a/mygpo/directory/management/commands/update-toplist.py b/mygpo/directory/management/commands/update-toplist.py index 97699ef5..ebca2683 100644 --- a/mygpo/directory/management/commands/update-toplist.py +++ b/mygpo/directory/management/commands/update-toplist.py @@ -4,7 +4,6 @@ from django.core.management.base import BaseCommand from mygpo.podcasts.models import Podcast from mygpo.utils import progress -from mygpo.db.couchdb.podcast import all_podcasts from mygpo.directory.tasks import update_podcast_subscribers @@ -20,8 +19,8 @@ class Command(BaseCommand): silent = options.get('silent') - podcasts = all_podcasts() - total = Podcast.objects.count() + podcasts = Podcast.objects.all() + total = podcasts.count() for n, podcast in enumerate(podcasts): update_podcast_subscribers.delay(podcast.get_id()) -- 2.11.4.GIT