<commit_before><commit_msg>Add data migrations to populate broadcast send all field<commit_after># -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-06 17:33
from __future__ import unicode_literals

from django.db import migrations
from temba.utils import chunk_list


def do_populate_send_all(Broadcast):
    broadcast_ids = Broadcast.objects.all().values_list('id', flat=True)

    for chunk in chunk_list(broadcast_ids, 1000):
        Broadcast.objects.filter(pk__in=chunk).update(send_all=False)


def apply_as_migration(apps, schema_editor):
    Broadcast = apps.get_model('msgs', 'Broadcast')
    do_populate_send_all(Broadcast)


def apply_manual():
    from temba.msgs.models import Broadcast
    do_populate_send_all(Broadcast)


class Migration(migrations.Migration):

    dependencies = [
        ('msgs', '0086_broadcast_send_all'),
    ]

    operations = [
        migrations.RunPython(apply_as_migration)
    ]
{'fraction_non_alphanumeric': 0.10032017075773746, 'fraction_numerical': 0.026680896478121666, 'mean_word_length': 4.485380116959064, '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': '1690319', 'n_tokens_mistral': 326, 'n_tokens_neox': 301, 'n_words': 62}