<commit_before># -*- coding: utf8 -*-

from CharacterModel import CharacterModel
from Model import Model
import datetime


class PlayerModel(CharacterModel):
    def __init__(self, idCharacter=None):
        super(PlayerModel, self).__init__(idCharacter)
        self._playerFields = dict()

    def getPk(self):
        return self._playerFields["id_player"]

    @staticmethod
    def loadByLoginAndPassword(login, password):
        query = "\
            SELECT\
                id_player,\
                login,\
                p.id_character,\
                name,\
                id_species,\
                id_gender\
            FROM\
                player AS p\
                join 'character' AS c ON p.id_character = c.id_character\
            WHERE\
                login = ? AND password = ?\
        "

        model = Model.fetchOneRow(query, (login, password))

        if len(model) > 0:
            pm = PlayerModel(model['id_character'])
            pm._setPk(model['id_player'])
            pm.setLogin(model['login'])
            pm.setIdCharacter(model['id_character'])
            return pm

        return None

    @staticmethod
    def loadByLogin(login):
        query = "\
            SELECT\
                id_player,\
                login\
            FROM\
                player\
            WHERE\<commit_msg>changes in sql queries<commit_after># -*- coding: utf8 -*-

from CharacterModel import CharacterModel
from Model import Model
import datetime


class PlayerModel(CharacterModel):
    def __init__(self, idCharacter=None):
        super(PlayerModel, self).__init__(idCharacter)
        self._playerFields = dict()

    def getPk(self):
        return self._playerFields["id_player"]

    @staticmethod
    def loadByLoginAndPassword(login, password):
        query = "\
            SELECT\
                id_player,\
                login,\
                id_character\
            FROM\
                player\
            WHERE\
                login = ? AND password = ?\
        "

        model = Model.fetchOneRow(query, (login, password))

        if len(model) > 0:
            pm = PlayerModel(model['id_character'])
            pm._setPk(model['id_player'])
            pm.setLogin(model['login'])
            pm.setIdCharacter(model['id_character'])
            return pm

        return None

    @staticmethod
    def loadByLogin(login):
        query = "\
            SELECT\
                id_player,\
                login,\
                id_character\
            FROM\
                player\
            WHERE\
{'fraction_non_alphanumeric': 0.09400386847195358, 'fraction_numerical': 0.0015473887814313346, 'mean_word_length': 1.4581749049429658, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4066739', 'n_tokens_mistral': 689, 'n_tokens_neox': 645, 'n_words': 149}