<commit_before><?php

namespace app\controllers;

use yii\console\Controller;
use Yii;
use app\components\CrontabManager;
use app\models\Cron;

class CrontabController extends Controller {
    
    public function beforeAction($action) {
        if (parent::beforeAction($action)) {
            return Yii::$app->id == "mqg-proxy-agg-console";
        } else {
            return false;
        }
    }

    private function getExecutionPath($taskId) {
        return Yii::$app->basePath."/yii crontab/task ".$taskId;
    }
    
    public function actionStart() {
        $crontab = new CrontabManager();
        $job = $crontab->newJob();
        $job->on('* * * * *');
        $job->doJob(Yii::$app->basePath."/yii crontab/listener");
        $crontab->add($job);
        $crontab->save(false);
        echo "MEICAN Crontab Service Started\n";
    }
    
    public function actionStop() {
        $crontab = new CrontabManager();
        $job = $crontab->newJob();
        $job->on('* 1 * * *');
        $job->doJob("stopping service...");
        $crontab->add($job);
        $crontab->save(false);
        $this->delete($job->id);
        echo "MEICAN Crontab Service Stopped\n";
    }
    
    public function actionListener() {
        $crons = Cron::find()
            ->where(['in' , 'status', [Cron::STATUS_PROCESSING, Cron::STATUS_DELETED]])
            ->orWhere(['external_id'=> null])->all();
        if ($crons) {
            foreach ($crons as $cron) {
                if ($cron->external_id != null) $this->delete($cron->external_id);
                
                switch ($cron->status) {<commit_msg>fix on crontab service<commit_after><?php

namespace app\controllers;

use yii\console\Controller;
use Yii;
use app\components\CrontabManager;
use app\models\Cron;

class CrontabController extends Controller {
    
    public function beforeAction($action) {
        if (parent::beforeAction($action)) {
            return Yii::$app->id == "mqg-proxy-agg-console";
        } else {
            return false;
        }
    }

    private function getExecutionPath($taskId) {
        return Yii::$app->basePath."/yii crontab/task ".$taskId;
    }
    
    public function actionStart() {
        $crontab = new CrontabManager();
        $job = $crontab->newJob();
        $job->on('* * * * *');
        $job->doJob(Yii::$app->basePath."/yii crontab/listener");
        $crontab->add($job);
        $crontab->save(false);
        echo "Crontab Service Started\n";
    }
    
    public function actionStop() {
        $crontab = new CrontabManager();
        $job = $crontab->newJob();
        $job->on('* 1 * * *');
        $job->doJob("stopping service...");
        $crontab->add($job);
        $crontab->save(false);
        $this->delete($job->id);
        echo "Crontab Service Stopped\n";
    }
    
    public function actionListener() {
        $crons = Cron::find()
            ->where(['in' , 'status', [Cron::STATUS_PROCESSING, Cron::STATUS_DELETED]])
            ->orWhere(['external_id'=> null])->all();
        if ($crons) {
            foreach ($crons as $cron) {
                if ($cron->external_id != null) $this->delete($cron->external_id);
                
                switch ($cron->status) {
{'fraction_non_alphanumeric': 0.16610064834825564, 'fraction_numerical': 0.0006174745291756715, 'mean_word_length': 2.195266272189349, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, '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': '4207339', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1029, 'n_words': 189}