ENHANCEMENT: added lastrun possibility

This commit is contained in:
Jeroen De Meerleer 2021-05-29 14:51:19 +02:00
parent 0f975c036f
commit 280af12470
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
1 changed files with 9 additions and 2 deletions

View File

@ -38,9 +38,16 @@ class Job extends Repository
public function getJobsDue()
{
$jobsSql = "SELECT id FROM job WHERE (nextrun <= :timestamp AND running IN (0,2)) OR (running IN (0,1,2) AND running < :timestamprun)";
$jobsSql = "SELECT id
FROM job
WHERE (
nextrun <= :timestamp
AND (lastrun IS NULL OR lastrun > :timestamplastrun)
AND running IN (0,2)
)
OR (running NOT IN (0,1,2) AND running < :timestamprun)";
$jobsStmt = $this->dbcon->prepare($jobsSql);
$jobsRslt = $jobsStmt->executeQuery([':timestamp' => time(), ':timestamprun' => time()]);
$jobsRslt = $jobsStmt->executeQuery([':timestamp' => time(), ':timestamplastrun' => time(), ':timestamprun' => time()]);
$jobs = $jobsRslt->fetchAllAssociative();
$return = [];
foreach ($jobs as $job) {