<commit_before>"""Model for handling operations on map data"""
import json

def persist_map(map_data, metadata, cursor, player_id):
    """Method for persisting map data"""
    serialized_map_data = json.dumps(map_data)

    map_sql = """INSERT INTO maps
                (download_code, map_hash, player_id)
                VALUES (%s, %s, %s)"""

    cursor.execute(map_sql, (metadata['code'], metadata['hash'], player_id))

    last_id_sql = "SELECT LAST_INSERT_ID()"
    cursor.execute(last_id_sql)

    last_id = cursor.fetchone()

    map_data_sql = "INSERT INTO maps_data (map_id, json) VALUES (%s, %s)"

    cursor.execute(map_data_sql, (last_id[0], serialized_map_data))

def find_map(map_code, cursor):
    """Method for retrieving map data"""
    map_code_sql = "SELECT id FROM maps WHERE download_code = %s"
    cursor.execute(map_code_sql, (map_code,))
    map_id = cursor.fetchone()

    if not map_id:
        return None

    map_data_sql = "SELECT json FROM maps_data WHERE map_id = %s"
    cursor.execute(map_data_sql, (map_id[0],))
    map_data = cursor.fetchone()

    return json.loads(map_data[0])<commit_msg>Change map download code to be case insensitive<commit_after>"""Model for handling operations on map data"""
import json

def persist_map(map_data, metadata, cursor, player_id):
    """Method for persisting map data"""
    serialized_map_data = json.dumps(map_data)

    map_sql = """INSERT INTO maps
                (download_code, map_hash, player_id)
                VALUES (%s, %s, %s)"""

    cursor.execute(map_sql, (metadata['code'], metadata['hash'], player_id))

    last_id_sql = "SELECT LAST_INSERT_ID()"
    cursor.execute(last_id_sql)

    last_id = cursor.fetchone()

    map_data_sql = "INSERT INTO maps_data (map_id, json) VALUES (%s, %s)"

    cursor.execute(map_data_sql, (last_id[0], serialized_map_data))

def find_map(map_code, cursor):
    """Method for retrieving map data"""
    map_code_sql = "SELECT id FROM maps WHERE download_code = %s"
    cursor.execute(map_code_sql, (map_code.upper(),))
    map_id = cursor.fetchone()

    if not map_id:
        return None

    map_data_sql = "SELECT json FROM maps_data WHERE map_id = %s"
    cursor.execute(map_data_sql, (map_id[0],))
    map_data = cursor.fetchone()

    return json.loads(map_data[0])
{'fraction_non_alphanumeric': 0.12380538662033015, 'fraction_numerical': 0.0026064291920069507, 'mean_word_length': 3.787941787941788, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7522861', 'n_tokens_mistral': 789, 'n_tokens_neox': 757, 'n_words': 192}