<commit_before># -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-22 15:32
from __future__ import unicode_literals

from django.db import migrations
from uuid import uuid4


def populate_flow_start_uuid(FlowStart):
    start_ids = list(FlowStart.objects.filter(uuid=None).values_list('id', flat=True))
    if not start_ids:
        return

    print("Fetched %d flow start ids that need UUIDs..." % len(start_ids))
    num_updated = 0

    for start_id in start_ids:
        FlowStart.objects.filter(id=start_id).update(uuid=uuid4())
        num_updated += 1

        if num_updated % 1000 == 0:
            print(" > Updated %d of %d flow starts" % (num_updated, len(start_ids)))


def apply_manual():
    from temba.flows.models import FlowStart
    populate_flow_start_uuid(FlowStart)<commit_msg>Hot fix to flow start UUID migration<commit_after># -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-22 15:32
from __future__ import unicode_literals

from django.db import migrations
from uuid import uuid4


def populate_flow_start_uuid(FlowStart):
    start_ids = list(FlowStart.objects.values_list('id', flat=True))
    if not start_ids:
        return

    print("Fetched %d flow start ids that need UUIDs..." % len(start_ids))
    num_updated = 0

    for start_id in start_ids:
        FlowStart.objects.filter(id=start_id).update(uuid=uuid4())
        num_updated += 1

        if num_updated % 1000 == 0:
            print(" > Updated %d of %d flow starts" % (num_updated, len(start_ids)))


def apply_manual():
    from temba.flows.models import FlowStart
    populate_flow_start_uuid(FlowStart)
{'fraction_non_alphanumeric': 0.10558624923265807, 'fraction_numerical': 0.03192142418661756, 'mean_word_length': 3.453551912568306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6716778', 'n_tokens_mistral': 570, 'n_tokens_neox': 518, 'n_words': 143}