$cache = Yii::$app->cache;
$task = $cache->get($cacheKey);
-
- if (!is_array($task) || empty($task['taskName']) || $task['taskName'] !== 'apRecalculate') {
+ $this->stdout(json_encode($task, JSON_UNESCAPED_UNICODE));
+ if (!is_array($task) || empty($task['taskName']) || $task['taskName'] !== 'apRecalculateTask') {
$this->stdout("No pending apRecalculateTask\n");
return ExitCode::OK;
}
}
}
- if (abs(time() - $task['startTime']) > 86400) {
+ if (abs(time() - strtotime($task['startTime'])) > 86400) {
$this->stdout("Task startTime is out of allowed window\n");
$task['status'] = 'error';
$task['error'] = 'Invalid startTime';
'year' => $year,
'month' => $month,
'storeId' => $store,
- 'status' => 'running',
+ 'status' => 'pending',
'startTime' => date('Y-m-d H:i:s'),
'progress' => 0,
'error' => null
];
Yii::$app->cache->set($taskName, $cacheValue, 3600);
- return $this->asJson(['status' => 'started' ]);
+ return $this->asJson(['status' => 'started', 'data' => Yii::$app->cache->get('apRecalculateTask') ]);
}
public function actionCheckTask()
month: $('#dynamicmodel-month').val(),
store_id: store_id
},
- success: function () {
+ success: function (data) {
startTaskPolling();
$('#rebuild').prop('disabled', true);
+ console.log(data.data);
},
error: function () {
alert('Ошибка запуска пересчёта!');