Permalink
Browse files

Scheduler: remove unused method.

  • Loading branch information...
1 parent 68d521e commit c3688e920910cbde5bbc696cda1e6f67d6152714 @cdujeu cdujeu committed Jul 20, 2016
Showing with 35 additions and 55 deletions.
  1. +35 −55 core/src/plugins/action.scheduler/src/Scheduler.php
@@ -493,23 +493,41 @@ public function listTasks($httpVars, $rootPath, $relativePath, $paginationHash =
*/
protected function taskToNode(Task $task, $basePath, $dateFormat, $isChild = false){
- $s = $task->getSchedule()->getValue();
- $meta = [
- "task_id" => $task->getId(),
- "icon" => "scheduler/ICON_SIZE/task.png",
- "ajxp_mime" => ($isChild ? "scheduler_task":"scheduler_task"), // TODO: introduce a different mime for jobs?
- "schedule" => $s,
- "text" => ($isChild ? " ---- job running" : $task->getLabel()),
- "label" => ($isChild ? " ---- job running" : $task->getLabel()),
- "action_name" => $task->getAction(),
- "repository_id" => $task->getWsId(),
- "user_id" => $task->getUserId(),
- "STATUS" => $task->getStatusMessage()
- ];
- $cron = CronExpression::factory($s);
- $next = $cron->getNextRunDate();
- $meta["NEXT_EXECUTION"] = ($isChild ? "-" : $next->format($dateFormat));
- $meta["LAST_EXECUTION"] = "-";
+ if($isChild){
+ $label = ($task->getStatus() === Task::STATUS_FAILED ? " --- ERROR" : " --- JOB RUNNING");
+ $meta = [
+ "task_id" => $task->getId(),
+ "icon" => "scheduler/ICON_SIZE/task.png",
+ "ajxp_mime" => "scheduler_task", // TODO: introduce a different mime for jobs?
+ "text" => $label,
+ "label" => $label,
+ "schedule" => $task->getStatusMessage(),
+ "action_name" => "",
+ "repository_id" => "",
+ "user_id" => "",
+ "STATUS" => "",
+ "NEXT_EXECUTION" => "",
+ "LAST_EXECUTION" => "Started on ". $task->getCreationDate()->format($dateFormat),
+ ];
+ }else{
+ $s = $task->getSchedule()->getValue();
+ $meta = [
+ "task_id" => $task->getId(),
+ "icon" => "scheduler/ICON_SIZE/task.png",
+ "ajxp_mime" => "scheduler_task",
+ "schedule" => $s,
+ "text" => $task->getLabel(),
+ "label" => $task->getLabel(),
+ "action_name" => $task->getAction(),
+ "repository_id" => $task->getWsId(),
+ "user_id" => $task->getUserId(),
+ "STATUS" => $task->getStatusMessage()
+ ];
+ $cron = CronExpression::factory($s);
+ $next = $cron->getNextRunDate();
+ $meta["NEXT_EXECUTION"] = $next->format($dateFormat);
+ $meta["LAST_EXECUTION"] = "-";
+ }
$key = $basePath."/".$task->getId();
return new AJXP_Node($key, $meta);
@@ -539,42 +557,4 @@ protected function migrateLegacyTasks(){
@unlink($dbFile);
}
- /**
- * @param $taskId
- * @param $label
- * @param $schedule
- * @param $actionName
- * @param $repositoryIds
- * @param $userId
- * @param $paramsArray
- * @throws Exception
- */
- public function addOrUpdateTask($taskId, $label, $schedule, $actionName, $repositoryIds, $userId, $paramsArray)
- {
- $tasks = FileHelper::loadSerialFile($this->getDbFile(), false, "json");
- if (isSet($taskId)) {
- foreach ($tasks as $index => $task) {
- if ($task["task_id"] == $taskId) {
- $data = $task;
- $theIndex = $index;
- }
- }
- }
- if (!isSet($theIndex)) {
- $data = array();
- $data["task_id"] = substr(md5(time()), 0, 16);
- }
- $data["label"] = $label;
- $data["schedule"] = $schedule;
- $data["action_name"] = $actionName;
- $data["repository_id"] = $repositoryIds;
- $data["user_id"] = $userId;
- $data["PARAMS"] = $paramsArray;
- if (isSet($theIndex)) $tasks[$theIndex] = $data;
- else $tasks[] = $data;
- FileHelper::saveSerialFile($this->getDbFile(), $tasks, true, false, "json");
-
- }
-
-
}

0 comments on commit c3688e9

Please sign in to comment.