<commit_before># -*- coding: utf-8 -*-
# Generated by Django 1.11.28 on 2020-05-15 15:52
from __future__ import unicode_literals
import re

from django.db import migrations

REGEX = re.compile("({%\ ?journal_url 'do_review' review_assignment.id\ ?%})")
OUTPUT = "{{ review_url }}"

def replace_template(apps, schema_editor):
    SettingValueTranslation = apps.get_model('core', 'SettingValueTranslation')
    settings = SettingValueTranslation.objects.all()

    for setting in settings:
        setting.value = re.sub(REGEX, OUTPUT, setting.value)
        setting.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0038_xslt_1-3-8'),
    ]

    operations = [
        migrations.RunPython(replace_template, reverse_code=migrations.RunPython.noop)
    ]<commit_msg>Handle migrating non-string values (i.e.: NULL)<commit_after># -*- coding: utf-8 -*-
# Generated by Django 1.11.28 on 2020-05-15 15:52
from __future__ import unicode_literals
import re

from django.db import migrations

REGEX = re.compile("({%\ ?journal_url 'do_review' review_assignment.id\ ?%})")
OUTPUT = "{{ review_url }}"

def replace_template(apps, schema_editor):
    SettingValueTranslation = apps.get_model('core', 'SettingValueTranslation')
    settings = SettingValueTranslation.objects.all()

    for setting in settings:
        if isinstance(setting.value, str):
            setting.value = re.sub(REGEX, OUTPUT, setting.value)
            setting.save()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0038_xslt_1-3-8'),
    ]

    operations = [
        migrations.RunPython(replace_template, reverse_code=migrations.RunPython.noop)
    ]
{'fraction_non_alphanumeric': 0.12729425695677915, 'fraction_numerical': 0.02960331557134399, 'mean_word_length': 3.76056338028169, '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': '2392208', 'n_tokens_mistral': 561, 'n_tokens_neox': 513, 'n_words': 112}