diff options
Diffstat (limited to 'lib/Service/StatusService.php')
-rw-r--r-- | lib/Service/StatusService.php | 27 |
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; + } } |