<commit_before># encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models

class Migration(DataMigration):

    def forwards(self, orm):
        for pa in orm.PoliticianAlert.objects.filter(active=True).select_related('politician'):
            query = u'MP: "%s" Type: "debate"' % pa.politician.slug
            topic, created = orm.Topic.objects.get_or_create(query=query)
            user, created = orm['accounts.User'].objects.get_or_create(email=pa.email)
            subscription, created = orm.Subscription.objects.get_or_create(
                topic=topic,
                user=user,
                created=pa.created,
                active=pa.active
            )
        print "PoliticianAlert objects converted."
        print "You now need to call topic.initialize_if_necessary so that initial alerts"
        print "don't contain old items."
        print "Press Enter to continue"
        raw_input()
<commit_msg>Correct syntax of get_or_create call in migration<commit_after># encoding: utf-8
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models

class Migration(DataMigration):

    def forwards(self, orm):
        for pa in orm.PoliticianAlert.objects.filter(active=True).select_related('politician'):
            query = u'MP: "%s" Type: "debate"' % pa.politician.slug
            topic, created = orm.Topic.objects.get_or_create(query=query)
            user, created = orm['accounts.User'].objects.get_or_create(email=pa.email)
            subscription, created = orm.Subscription.objects.get_or_create(
                topic=topic,
                user=user,
                defaults={
                    'created': pa.created,
                    'active': pa.active
                }
            )
        print "PoliticianAlert objects converted."
        print "You now need to call topic.initialize_if_necessary so that initial alerts"
        print "don't contain old items."
        print "Press Enter to continue"
        raw_input()

{'fraction_non_alphanumeric': 0.09169467114738358, 'fraction_numerical': 0.0019203072491598655, 'mean_word_length': 2.4108019639934533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3863696', 'n_tokens_mistral': 581, 'n_tokens_neox': 561, 'n_words': 151}