<commit_before><?php
    class Error extends ActiveRecordBase {
        protected static $attributes = [ 'gameid', 'userid', 'description', 'actual', 'expected' ];
        protected static $tableName = 'errors';
        protected $gameid;
        protected $userid;
        public $game;
        public $user;
        public $description;
        public $actual;
        public $expected;

        public function __construct( $id = false ) {
            if ( $id !== false ) {
                $errorArray = dbSelectOne( 'errors', [ 'gameid', 'description', 'userid', 'actual', 'expected' ], compact( 'id' ) );
                $this->gameid = $errorArray[ 'gameid' ];
                $this->userid = $errorArray[ 'userid' ];
                $this->description = $errorArray[ 'description' ];
                $this->actual = $errorArray[ 'actual' ];
                $this->expected = $errorArray[ 'expected' ];
                $this->game = new Game( $this->gameid );
                $this->user = new User( $this->userid );
            }
        }

        public function onBeforeCreate() {
            if ( isset( $this->game ) ) {
                assert( $this->game instanceof Game, '$error->game must be an instance of Game' );
                $this->gameid = $this->game->id;
            }
            else {
                $this->gameid = 0;
            }
            assert( $this->user instanceof User, '$error->user must be an instance of User' );
            $this->userid = $this->user->id;
        }

        public static function findErrorsByGameAndUser( $gameid, $userid ) {
            assert( $gameid > 0, 'gameid must be a positive number' );
            assert( $userid > 0, 'userid must be a positive number' );

            $errorsArray = dbSelect(
                'errors',
                [ 'id' ],<commit_msg>Make actual and expected not mandatory<commit_after><?php
    require_once 'models/game.php';

    class Error extends ActiveRecordBase {
        protected static $attributes = [ 'gameid', 'userid', 'description', 'actual', 'expected' ];
        protected static $tableName = 'errors';
        protected $gameid;
        protected $userid;
        public $game;
        public $user;
        public $description;
        public $actual;
        public $expected;

        public function __construct( $id = false ) {
            if ( $id !== false ) {
                $errorArray = dbSelectOne( 'errors', [ 'gameid', 'description', 'userid', 'actual', 'expected' ], compact( 'id' ) );
                $this->id = $id;
                $this->gameid = $errorArray[ 'gameid' ];
                $this->userid = $errorArray[ 'userid' ];
                $this->description = $errorArray[ 'description' ];
                $this->actual = $errorArray[ 'actual' ];
                $this->expected = $errorArray[ 'expected' ];
                $this->game = new Game( $this->gameid );
                $this->user = new User( $this->userid );
            }
        }

        public function onBeforeCreate() {
            if ( isset( $this->game ) ) {
                assert( $this->game instanceof Game, '$error->game must be an instance of Game' );
                $this->gameid = $this->game->id;
            }
            else {
                $this->gameid = 0;
            }
            if ( !isset( $this->actual ) ) {
                $this->actual = '';
            }
            if ( !isset( $this->expected ) ) {
                $this->expected = '';
            }
            assert( $this->user instanceof User, '$error->user must be an instance of User' );
            $this->userid = $this->user->id;
        }

        public static function findErrorsByGameAndUser( $gameid, $userid ) {
            assert( $gameid > 0, 'gameid must be a positive number' );
            assert( $userid > 0, 'userid must be a positive number' );

            $errorsArray = dbSelect(
                'errors',
                [ 'id' ],
{'fraction_non_alphanumeric': 0.13968173781257892, 'fraction_numerical': 0.0015155342258145997, 'mean_word_length': 1.6702629804450437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, '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': '572386', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1043, 'n_words': 287}