<commit_before># Generated by Django 3.1.6 on 2021-04-20 15:30

from django.db import migrations, models
import logging
from seqr.utils.logging_utils import log_model_update, log_model_bulk_update

logger = logging.getLogger(__name__)


def merge_project_sanger_tags(apps, schema_editor):
    VariantTagType = apps.get_model("seqr", "VariantTagType")
    VariantTag = apps.get_model("seqr", "VariantTag")
    db_alias = schema_editor.connection.alias
    project_sanger_tag_types = VariantTagType.objects.using(db_alias).filter(name='Sanger in progress')
    if project_sanger_tag_types:
        logger.info('Merging "Sanger in progress" tags from {} projects'.format(len(project_sanger_tag_types)))
        main_tag_type = project_sanger_tag_types[0]
        main_tag_type.project=None
        main_tag_type.save()
        for sanger_tag_type in project_sanger_tag_types[1:]:
            tag_models = VariantTag.objects.using(db_alias).filter(variant_tag_type=sanger_tag_type)
            log_model_bulk_update(logger, tag_models, user=None, update_type='update', update_fields=['variant_tag_type'])
            tag_models.update(variant_tag_type=main_tag_type)
            log_model_update(logger, sanger_tag_type, user=None, update_type='delete')<commit_msg>clean up<commit_after># Generated by Django 3.1.6 on 2021-04-20 15:30

from django.db import migrations, models
from django.utils import timezone
import logging
from seqr.utils.logging_utils import log_model_update, log_model_bulk_update

logger = logging.getLogger(__name__)


def merge_project_sanger_tags(apps, schema_editor):
    VariantTagType = apps.get_model("seqr", "VariantTagType")
    VariantTag = apps.get_model("seqr", "VariantTag")
    db_alias = schema_editor.connection.alias
    project_sanger_tag_types = VariantTagType.objects.using(db_alias).filter(name='Sanger in progress')
    if project_sanger_tag_types:
        logger.info('Merging "Sanger in progress" tags from {} projects'.format(len(project_sanger_tag_types)))
        main_tag_type = project_sanger_tag_types[0]
        main_tag_type.project=None
        main_tag_type.last_modified_date=timezone.now()
        log_model_update(logger, main_tag_type, user=None, update_type='update', update_fields=['project', 'last_modified_date'])
        main_tag_type.save()

        for sanger_tag_type in project_sanger_tag_types[1:]:
            tag_models = VariantTag.objects.using(db_alias).filter(variant_tag_type=sanger_tag_type)
            log_model_bulk_update(logger, tag_models, user=None, update_type='update', update_fields=['variant_tag_type'])
            tag_models.update(variant_tag_type=main_tag_type)
            log_model_update(logger, sanger_tag_type, user=None, update_type='delete')
{'fraction_non_alphanumeric': 0.09495982468955443, 'fraction_numerical': 0.01241782322863404, 'mean_word_length': 5.1002227171492205, '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': '1550569', 'n_tokens_mistral': 902, 'n_tokens_neox': 874, 'n_words': 143}