<commit_before>import logging

from odoo import SUPERUSER_ID, api

_logger = logging.getLogger(__name__)


def migrate(cr, version):
    _logger.info("Recompute the related gender on mandate")

    with api.Environment.manage():
        env = api.Environment(cr, SUPERUSER_ID, {})
        for model_name in ["sta.mandate", "ext.mandate", "int.mandate"]:
            model = env[model_name]
            env.add_to_compute(model._fields["gender"], model.search([]))
            model.recompute()<commit_msg>Optimise mozaik_mandate_female_label migration<commit_after>import logging

from psycopg2.extensions import AsIs

_logger = logging.getLogger(__name__)


def migrate(cr, version):
    _logger.info("Recompute the related gender on mandate")

    for table_name in ["sta_mandate", "ext_mandate", "int_mandate"]:
        cr.execute(
            "UPDATE %(table_name)s SET gender = 'male' WHERE gender = 'm'",
            {"table_name": AsIs(table_name)},
        )
        cr.execute(
            "UPDATE %(table_name)s SET gender = 'female' WHERE gender = 'f'",
            {"table_name": AsIs(table_name)},
        )
{'fraction_non_alphanumeric': 0.12321428571428572, 'fraction_numerical': 0.0008928571428571428, 'mean_word_length': 3.2142857142857144, 'pattern_counts': {'":': 2, '<': 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': '6203021', 'n_tokens_mistral': 354, 'n_tokens_neox': 342, 'n_words': 80}