mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Add methods to manage scheduled tasks
This commit is contained in:
parent
caf882fed0
commit
5ff2f15485
2 changed files with 52 additions and 0 deletions
|
|
@ -194,6 +194,30 @@ class Queue
|
|||
return $driver->addTaskAtInterval($interval, $handler, $args, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a scheduled task if it exists.
|
||||
*
|
||||
* @param int $task_srl
|
||||
* @return ?object
|
||||
*/
|
||||
public static function getScheduledTask(int $task_srl): ?object
|
||||
{
|
||||
$driver = self::getDbDriver();
|
||||
return $driver->getScheduledTask($task_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a scheduled task.
|
||||
*
|
||||
* @param int $task_srl
|
||||
* @return bool
|
||||
*/
|
||||
public static function cancelScheduledTask(int $task_srl): bool
|
||||
{
|
||||
$driver = self::getDbDriver();
|
||||
return $driver->cancelScheduledTask($task_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the process key.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -190,6 +190,21 @@ class DB implements QueueInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a scheduled task by its task_srl.
|
||||
*
|
||||
* @param int $task_srl
|
||||
* @return ?object
|
||||
*/
|
||||
public function getScheduledTask(int $task_srl): ?object
|
||||
{
|
||||
$oDB = RFDB::getInstance();
|
||||
$stmt = $oDB->query('SELECT * FROM task_schedule WHERE task_srl = ?', [$task_srl]);
|
||||
$task = $stmt->fetchObject();
|
||||
$stmt->closeCursor();
|
||||
return $task ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scheduled tasks.
|
||||
*
|
||||
|
|
@ -270,4 +285,17 @@ class DB implements QueueInterface
|
|||
$stmt->execute([date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), $task->task_srl]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a scheduled task.
|
||||
*
|
||||
* @param int $task_srl
|
||||
* @return bool
|
||||
*/
|
||||
public function cancelScheduledTask(int $task_srl): bool
|
||||
{
|
||||
$oDB = RFDB::getInstance();
|
||||
$stmt = $oDB->query('DELETE FROM task_schedule WHERE task_srl = ?', [$task_srl]);
|
||||
return ($stmt && $stmt->rowCount()) ? true : false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue