46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\NuqloudScrum\BackgroundJob;
|
|
|
|
use OCA\NuqloudScrum\AppInfo\Application;
|
|
use OCA\NuqloudScrum\Service\ConfigService;
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
use OCP\BackgroundJob\TimedJob;
|
|
|
|
abstract class AbstractScrumJob extends TimedJob {
|
|
public function __construct(ITimeFactory $time) {
|
|
parent::__construct($time);
|
|
$this->setInterval($this->getIntervalSeconds());
|
|
}
|
|
|
|
protected function run($argument): void {
|
|
try {
|
|
/** @var ConfigService $configService */
|
|
$configService = \OC::$server->query(ConfigService::class);
|
|
if (!$configService->isRunnable()) {
|
|
return;
|
|
}
|
|
$this->runEnabled($argument);
|
|
} catch (\Throwable $e) {
|
|
try {
|
|
\OC::$server->getLogger()->warning($this->getFailureMessage(), [
|
|
'app' => Application::APP_ID,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
} catch (\Throwable) {
|
|
// Runtime failures are non-fatal during the scaffold phase.
|
|
}
|
|
}
|
|
}
|
|
|
|
abstract protected function runEnabled($argument): void;
|
|
|
|
abstract protected function getFailureMessage(): string;
|
|
|
|
protected function getIntervalSeconds(): int {
|
|
return 300;
|
|
}
|
|
}
|