summaryrefslogtreecommitdiffstats
path: root/lib/Service/StatusService.php
diff options
context:
space:
mode:
authorBenjamin Brahmer <info@b-brahmer.de>2023-03-05 12:02:38 +0100
committerBenjamin Brahmer <info@b-brahmer.de>2023-03-13 14:39:15 +0100
commitea8002e2d9a4ea82d01987741aefcae275379ad9 (patch)
tree9fb781fc1705c7a224ed9d22a648461527de00f8 /lib/Service/StatusService.php
parent0d31caac83378abe369602b87e5e55e7cccb673d (diff)
add cron status badge to admin setting
Display a info card in the settings, indicating when the last news update job ran. Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
Diffstat (limited to 'lib/Service/StatusService.php')
-rw-r--r--lib/Service/StatusService.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/Service/StatusService.php b/lib/Service/StatusService.php
index a15f30c76..69a621e3c 100644
--- a/lib/Service/StatusService.php
+++ b/lib/Service/StatusService.php
@@ -16,6 +16,9 @@ namespace OCA\News\Service;
use OCA\News\AppInfo\Application;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\BackgroundJob\IJobList;
+use OCP\Util;
+use OCA\News\Cron\UpdaterJob;
class StatusService
{
@@ -25,14 +28,18 @@ class StatusService
private $appName;
/** @var IDBConnection */
private $connection;
+ /** @var IJobList */
+ private $jobList;
public function __construct(
IConfig $settings,
- IDBConnection $connection
+ IDBConnection $connection,
+ IJobList $jobList
) {
$this->settings = $settings;
$this->connection = $connection;
$this->appName = Application::NAME;
+ $this->jobList = $jobList;
}
/**
@@ -76,4 +83,22 @@ class StatusService
]
];
}
+
+ /**
+ * Get last update time
+ */
+ public function getUpdateTime(): int
+ {
+
+ $time = 0;
+
+ [$major, $minor, $micro] = Util::getVersion();
+
+ if ($major >= 26) {
+ $myJobList = $this->jobList->getJobsIterator(UpdaterJob::class, 1, 0);
+ $time = $myJobList->current()->getLastRun();
+ }
+
+ return $time;
+ }
}