diff options
author | Benjamin Brahmer <info@b-brahmer.de> | 2020-05-23 21:27:34 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-08-14 18:22:57 +0200 |
commit | 4ebc906fef787996497dc198e536e152e8be9bde (patch) | |
tree | 06fe6f4696c5b9af68f623a8a63231748daa7dbb /lib | |
parent | 1619dd379d79482e58696eea6c4fea7a03f9e65f (diff) |
Update to new BackgroudJob logic
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config/Config.php | 12 | ||||
-rw-r--r-- | lib/Controller/AdminController.php | 7 | ||||
-rw-r--r-- | lib/Cron/Updater.php | 7 | ||||
-rw-r--r-- | lib/Settings/Admin.php | 1 |
4 files changed, 24 insertions, 3 deletions
diff --git a/lib/Config/Config.php b/lib/Config/Config.php index dea1f5814..35d947871 100644 --- a/lib/Config/Config.php +++ b/lib/Config/Config.php @@ -32,6 +32,7 @@ class Config private $loggerParams; private $maxSize; private $exploreUrl; + private $updateInterval; public function __construct( Folder $fileSystem, @@ -48,6 +49,7 @@ class Config $this->logger = $logger; $this->exploreUrl = ''; $this->loggerParams = $LoggerParameters; + $this->updateInterval = 3600; } public function getAutoPurgeMinimumInterval() @@ -94,6 +96,10 @@ class Config return $this->exploreUrl; } + public function getUpdateInterval() + { + return $this->updateInterval; + } public function setAutoPurgeMinimumInterval($value) { @@ -135,6 +141,12 @@ class Config $this->exploreUrl = $value; } + public function setUpdateInterval($value) + { + $this->updateInterval = $value; + } + + public function read($configPath, $createIfNotExists = false) { diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 3ce09a0d1..a8fcf7891 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -73,6 +73,7 @@ class AdminController extends Controller 'useCronUpdates' => $this->config->getUseCronUpdates(), 'maxSize' => $this->config->getMaxSize(), 'exploreUrl' => $this->config->getExploreUrl(), + 'updateInterval' => $this->config->getupdateInterval(), ]; return new TemplateResponse($this->appName, 'admin', $data, 'blank'); } @@ -88,6 +89,7 @@ class AdminController extends Controller * @param int $maxSize New max feed size * @param bool $useCronUpdates Whether or not to use cron updates * @param string $exploreUrl URL to use for the explore feed + * @param int $updateInterval Interval in which the feeds will be updated * * @return array with the updated values */ @@ -98,7 +100,8 @@ class AdminController extends Controller $feedFetcherTimeout, $maxSize, $useCronUpdates, - $exploreUrl + $exploreUrl, + $updateInterval ) { $this->config->setAutoPurgeMinimumInterval($autoPurgeMinimumInterval); $this->config->setAutoPurgeCount($autoPurgeCount); @@ -107,6 +110,7 @@ class AdminController extends Controller $this->config->setFeedFetcherTimeout($feedFetcherTimeout); $this->config->setUseCronUpdates($useCronUpdates); $this->config->setExploreUrl($exploreUrl); + $this->config->setupdateInterval($updateInterval); $this->config->write($this->configPath); return [ @@ -118,6 +122,7 @@ class AdminController extends Controller 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), 'useCronUpdates' => $this->config->getUseCronUpdates(), 'exploreUrl' => $this->config->getExploreUrl(), + 'updateInterval' => $this->config->getupdateInterval(), ]; } } diff --git a/lib/Cron/Updater.php b/lib/Cron/Updater.php index 55afe0a38..66ca4a908 100644 --- a/lib/Cron/Updater.php +++ b/lib/Cron/Updater.php @@ -11,13 +11,13 @@ namespace OCA\News\Cron; -use OC\BackgroundJob\Job; +use OC\BackgroundJob\TimedJob; use OCA\News\Config\Config; use OCA\News\Service\StatusService; use OCA\News\Utility\Updater as UpdaterService; -class Updater extends Job +class Updater extends TimedJob { /** @@ -34,6 +34,7 @@ class Updater extends Job private $updaterService; public function __construct( + ITimeFactroy $time, Config $config, StatusService $status, UpdaterService $updaterService @@ -41,6 +42,8 @@ class Updater extends Job $this->config = $config; $this->status = $status; $this->updaterService = $updaterService; + + parent::setInterval($this->config->getupdateInterval()); } protected function run($argument) diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 737f44cc1..e8c9a0cb2 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -27,6 +27,7 @@ class Admin implements ISettings 'useCronUpdates' => $this->config->getUseCronUpdates(), 'maxSize' => $this->config->getMaxSize(), 'exploreUrl' => $this->config->getExploreUrl(), + 'updateInterval' => $this->config->getUpdateInterval(), ]; return new TemplateResponse('news', 'admin', $data, ''); } |