<commit_before><?php

namespace dlds\mlm\handlers;

use dlds\mlm\models\LogMlm;

class MlmResultHandler {

    /**
     * Logs mlm generator result
     * @param int $resultGenerating generatoring result code
     * @param int $resultSaving saving result code
     * @param array $overview generating overview
     */
    public static function logResult($resultGenerating, $resultSaving, array $overview)
    {
        // create log only if logging is enabled
        if (\Yii::$app->mlm->dbLogging)
        {
            // create new log object
            $log = new LogMlm();

            $log->setResultGenerator($resultGenerating);
            $log->setResultSaving($resultSaving);
            $log->setCommissions($overview);

            // try to save log, if it was unsuccessful notify developer
            if (!$log->save())
            {
                self::notify($resultGenerating, $overview);
            }
        }
    }

    /**
     * Notify developer about errors
     * @param int $resultGenerating generator result code
     * @param array $overview generating overview
     */
    public static function notify($resultGenerating, array $overview)
    {
        // make notification only if it is enabled
        if (\Yii::$app->mlm->errorsNotifications)
        {
            // notify developer by email
            mail(\Yii::$app->mlm->notifyEmail, \Yii::$app->mlm->getResultMessage($resultGenerating), var_export($overview));
        }
    }
}<commit_msg>Mlm Result fix<commit_after><?php

namespace dlds\mlm\handlers;

use dlds\mlm\models\LogMlm;

class MlmResultHandler {

    /**
     * Logs mlm generator result
     * @param int $resultGenerating generatoring result code
     * @param int $resultSaving saving result code
     * @param array $overview generating overview
     */
    public static function logResult($resultGenerating, $resultSaving, array $overview)
    {
        // create log only if logging is enabled
        if (\Yii::$app->mlm->dbLogging)
        {
            // create new log object
            $log = new LogMlm();

            $log->setResultGenerator($resultGenerating);
            $log->setResultSaving($resultSaving);
            $log->setCommissions($overview);

            // try to save log, if it was unsuccessful notify developer
            if (!$log->save())
            {
                self::notify($resultGenerating, $overview);
            }
        }
    }

    /**
     * Notify developer about errors
     * @param int $resultGenerating generator result code
     * @param array $overview generating overview
     */
    public static function notify($resultGenerating, array $overview)
    {
        // make notification only if it is enabled
        if (\Yii::$app->mlm->errorsNotifications)
        {
            $content = var_export($overview, true);

            // notify developer by email
            mail(\Yii::$app->mlm->notifiedEmail, \Yii::$app->mlm->getResultMessage($resultGenerating), $content);
        }
    }
}
{'fraction_non_alphanumeric': 0.10978441127694859, 'fraction_numerical': 0.0, 'mean_word_length': 2.181434599156118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '4894295', 'n_tokens_mistral': 822, 'n_tokens_neox': 805, 'n_words': 215}