From 1ade225fae9f71093265e3c349323ec48e86bd15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Thu, 19 Jun 2014 11:29:26 +0200 Subject: [PATCH] [Migration] Store podcast subscriber count --- mygpo/maintenance/migrate.py | 2 ++ .../podcasts/migrations/0017_podcast_subscribers.py | 20 ++++++++++++++++++++ mygpo/podcasts/models.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 mygpo/podcasts/migrations/0017_podcast_subscribers.py diff --git a/mygpo/maintenance/migrate.py b/mygpo/maintenance/migrate.py index 16883851..8da821db 100644 --- a/mygpo/maintenance/migrate.py +++ b/mygpo/maintenance/migrate.py @@ -8,6 +8,7 @@ import json from datetime import datetime from mygpo.podcasts.models import (Podcast, Episode, URL, Slug, Tag, MergedUUID, PodcastGroup, ) +from mygpo.db.couchdb.podcast_state import podcast_subscriber_count import logging logger = logging.getLogger(__name__) @@ -92,6 +93,7 @@ def migrate_podcast(p): 'twitter': getattr(p, 'twitter', None), 'group_member_name': p.group_member_name, 'update_interval': p.update_interval, + 'subscribers': podcast_subscriber_count(p), }) update_urls(p, p2) diff --git a/mygpo/podcasts/migrations/0017_podcast_subscribers.py b/mygpo/podcasts/migrations/0017_podcast_subscribers.py new file mode 100644 index 00000000..8b9cefec --- /dev/null +++ b/mygpo/podcasts/migrations/0017_podcast_subscribers.py @@ -0,0 +1,20 @@ +# encoding: utf8 +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('podcasts', '0015_auto_20140616_1105'), + ] + + operations = [ + migrations.AddField( + model_name='podcast', + name='subscribers', + field=models.PositiveIntegerField(default=0), + preserve_default=True, + ), + ] diff --git a/mygpo/podcasts/models.py b/mygpo/podcasts/models.py index 97ad6587..657a65f9 100644 --- a/mygpo/podcasts/models.py +++ b/mygpo/podcasts/models.py @@ -290,7 +290,7 @@ class Podcast(UUIDModel, TitleModel, DescriptionModel, LinkModel, # if p1 is related to p2, p2 is also related to p1 related_podcasts = models.ManyToManyField('self', symmetrical=True) - #subscribers = SchemaListProperty(SubscriberData) + subscribers = models.PositiveIntegerField(default=0) restrictions = models.CharField(max_length=20, null=False, blank=True, default='') common_episode_title = models.CharField(max_length=100, null=False, blank=True) -- 2.11.4.GIT