<commit_before># encoding: utf8
from __future__ import unicode_literals

from django.db import models, migrations  # noqa


def add_initial_tag(apps, schema_editor):
    # We can't import the PieceTag model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    PieceTag = apps.get_model("pieces", "PieceTag")
    Piece = apps.get_model("pieces", "Piece")

    initial_tag = PieceTag()
    initial_tag.name = "created-before-tagging"
    initial_tag.save()

    for piece in Piece.objects.all():
        piece.tags = [initial_tag]
        piece.save()


class Migration(migrations.Migration):
    dependencies = [
        ('pieces', '0004_add_piece_tagging'),
    ]

    operations = [
            migrations.RunPython(add_initial_tag),
    ]<commit_msg>Minor migration fix<commit_after># encoding: utf8
from __future__ import unicode_literals

from django.db import models, migrations  # noqa


def add_initial_tag(apps, schema_editor):
    # We can't import the PieceTag model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    PieceTag = apps.get_model("pieces", "PieceTag")
    Piece = apps.get_model("pieces", "Piece")

    initial_tag = PieceTag()
    initial_tag.name = "created-before-tagging"
    initial_tag.save()

    l = Piece.objects.all()
    for i, piece in enumerate(l):
        print i, len(l)
        piece.tags = [initial_tag]
        piece.save()


class Migration(migrations.Migration):
    dependencies = [
        ('pieces', '0004_add_piece_tagging'),
    ]

    operations = [
            migrations.RunPython(add_initial_tag),
    ]
{'fraction_non_alphanumeric': 0.1013189448441247, 'fraction_numerical': 0.005995203836930456, 'mean_word_length': 3.25765306122449, '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': '2753886', 'n_tokens_mistral': 532, 'n_tokens_neox': 509, 'n_words': 136}