private function scheduleNew() { $lastCheck = $this->jobDao->getLastCheck(); if ($lastCheck !== false && DateUtils::isSameMinute($this->now->format('Y-m-d H:i:s'), $lastCheck)) { return; } $this->jobDao->setLastCheck($this->now->format('Y-m-d H:i:s')); $this->logger->info('Schedule new tasks.'); $jobs = $this->jobDao->findRunnable(); foreach ($jobs as $job) { if (DateUtils::shouldRun($job['cron'], $this->now)) { $taskId = $this->createTask($job['id']); $this->tryRunTask($taskId); } } }
public function testIsSameMinute() { assert(DateUtils::isSameMinute('2015-01-02 03:04:05', '2015-01-02 03:04:06')); assert(!DateUtils::isSameMinute('2015-01-02 03:04:05', '2015-01-02 03:05:06')); }