Fixed checking if crontab is configured

This commit is contained in:
Taras Machyshyn
2017-11-24 17:36:38 +02:00
parent 30ebcf6d76
commit 67d47d59d3

View File

@@ -46,11 +46,11 @@ class ScheduledJob
protected $allowedMethod = 'run';
/**
* Last cron run time to check if crontab is configured properly
* Period to check if crontab is configured properly
*
* @var string
*/
protected $lastCronRunTime = '24 hours';
protected $checkingCronPeriod = '25 hours';
/**
* @var array - path to cron job files
@@ -208,8 +208,8 @@ class ScheduledJob
*/
public function isCronConfigured()
{
$nowDate = new \DateTime('now', new \DateTimeZone("UTC"));
$startDate = new \DateTime('-' . $this->lastCronRunTime, new \DateTimeZone("UTC"));
$startDate = new \DateTime('-' . $this->checkingCronPeriod, new \DateTimeZone("UTC"));
$endDate = new \DateTime('+' . $this->checkingCronPeriod, new \DateTimeZone("UTC"));
$query = "
SELECT job.id FROM scheduled_job
@@ -217,8 +217,8 @@ class ScheduledJob
WHERE
scheduled_job.job = 'Dummy'
AND scheduled_job.deleted = 0
AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $nowDate->format('Y-m-d H:i:s') ."'
AND (job.status IN ('Success', 'Failed') OR (job.status = 'Pending' AND job.execute_time >= '". $nowDate->modify('-1 hour')->format('Y-m-d H:i:s') ."') )
AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $endDate->format('Y-m-d H:i:s') ."'
AND job.status IN ('Success', 'Failed', 'Pending')
ORDER BY job.execute_time DESC
";