Files
srybkin c0defdb07e #133365: самовосстановление cron-задач, retention и деградация поля project
- catch (\Throwable) вместо \Exception в MoleController::actionIndex
- самовосстановление зависших строк (dateStart < now - stuckTimeout) прямо в actionIndex:
  сброс через reArm() или completed = 2 (COMPLETED_FAILED) после превышения maxRetries
- retention выполненных задач: config-параметр keepDays, MoleTask::forgetCompleted()
- фиксация логических часов: nextRunDate() — при ретрае/перепланировании dateAdd
  не остаётся в прошлом, а ставится now + period; счётчик попыток в status
- поле project устарело: убрано из выборки getAllTask(), форм, таблиц и поиска
2026-12-02 16:44:21 +04:00

91 lines
2.4 KiB
PHP

<?php
namespace dominion\cron\models\search;
use \Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use dominion\cron\models\MoleTask;
/**
* MoleTaskSearch represents the model behind the search form of `app\models\Articles`.
*/
class MoleTaskSearch extends MoleTask
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'parentId', 'isReady', 'completed', 'priority', 'childsTotalCount', 'childsCompleted', 'period'], 'integer'],
[['dateAdd', 'dateStart', 'dateEnd'], 'safe'],
[['params'], 'string'],
[['module', 'controller', 'type', 'name', 'status'], 'string', 'max' => 255],
[['project'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = MoleTask::find();
// add conditions that should always apply here
$this->load($params);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC
]
]
]);
if (!$this->validate())
{
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'parentId' => $this->parentId,
'isReady' => $this->isReady,
'completed' => $this->completed,
'priority' => $this->priority,
'childsTotalCount' => $this->childsTotalCount,
'childsCompleted' => $this->childsCompleted,
]);
$query->andFilterWhere(['like', 'params', $this->params])
->andFilterWhere(['like', 'controller', $this->controller])
->andFilterWhere(['like', 'module', $this->module])
->andFilterWhere(['like', 'type', $this->type])
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'status', $this->status]);
return $dataProvider;
}
}