From 8314c99b56e66c2b86dd32432bcf5ed94a3ece02 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 23 May 2016 20:43:51 -0400 Subject: Added QueueManager to process background jobs --- app/Job/BaseJob.php | 33 +++++++++++++++++++++++++++ app/Job/EmailJob.php | 54 ++++++++++++++++++++++++++++++++++++++++++++ app/Job/ProjectMetricJob.php | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 app/Job/BaseJob.php create mode 100644 app/Job/EmailJob.php create mode 100644 app/Job/ProjectMetricJob.php (limited to 'app/Job') diff --git a/app/Job/BaseJob.php b/app/Job/BaseJob.php new file mode 100644 index 00000000..60522ac6 --- /dev/null +++ b/app/Job/BaseJob.php @@ -0,0 +1,33 @@ +jobParams; + } +} diff --git a/app/Job/EmailJob.php b/app/Job/EmailJob.php new file mode 100644 index 00000000..9293a1d4 --- /dev/null +++ b/app/Job/EmailJob.php @@ -0,0 +1,54 @@ +jobParams = array($email, $name, $subject, $html, $author); + return $this; + } + + /** + * Execute job + * + * @access public + * @param string $email + * @param string $name + * @param string $subject + * @param string $html + * @param string $author + */ + public function execute($email, $name, $subject, $html, $author) + { + $this->logger->debug(__METHOD__.' Sending email to '.$email.' via '.MAIL_TRANSPORT); + $startTime = microtime(true); + + $this->emailClient + ->getTransport(MAIL_TRANSPORT) + ->sendEmail($email, $name, $subject, $html, $author) + ; + + if (DEBUG) { + $this->logger->debug('Email sent in '.round(microtime(true) - $startTime, 6).' seconds'); + } + } +} diff --git a/app/Job/ProjectMetricJob.php b/app/Job/ProjectMetricJob.php new file mode 100644 index 00000000..2c3e589c --- /dev/null +++ b/app/Job/ProjectMetricJob.php @@ -0,0 +1,40 @@ +jobParams = array($projectId); + return $this; + } + + /** + * Execute job + * + * @access public + * @param integer $projectId + */ + public function execute($projectId) + { + $this->logger->debug(__METHOD__.' Run project metrics calculation'); + $now = date('Y-m-d'); + + $this->projectDailyColumnStats->updateTotals($projectId, $now); + $this->projectDailyStats->updateTotals($projectId, $now); + } +} -- cgit v1.2.3