diff options
author | Joas Schilling <coding@schilljs.com> | 2017-05-10 11:54:27 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-05-10 12:06:09 +0200 |
commit | 266a1e88fa72935725244ad41d8be60332cafef5 (patch) | |
tree | e7c88bd33a9e118e1b79745f56e7b4fb8ddfdd55 /apps/lookup_server_connector | |
parent | 209b05489d442652fa4d7ce3a7b37568444b5ae4 (diff) | |
download | nextcloud-server-266a1e88fa72935725244ad41d8be60332cafef5.tar.gz nextcloud-server-266a1e88fa72935725244ad41d8be60332cafef5.zip |
Define method shouldRun
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/lookup_server_connector')
-rw-r--r-- | apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index faeef05da17..53c101cd933 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -19,11 +19,11 @@ * */ - namespace OCA\LookupServerConnector\BackgroundJobs; use OC\BackgroundJob\Job; +use OC\BackgroundJob\JobList; use OCP\BackgroundJob\IJobList; use OCP\Http\Client\IClientService; use OCP\ILogger; @@ -35,6 +35,8 @@ class RetryJob extends Job { private $jobList; /** @var string */ private $lookupServer = 'https://lookup.nextcloud.com/users'; + /** @var int how much time should be between two tries (10 minutes) */ + private $interval = 600; /** * @param IClientService $clientService @@ -53,12 +55,10 @@ class RetryJob extends Job { * @param ILogger $logger */ public function execute($jobList, ILogger $logger = null) { - if ($this->shouldRun($this->argument)) { parent::execute($jobList, $logger); $jobList->remove($this, $this->argument); } - } protected function run($argument) { @@ -81,9 +81,20 @@ class RetryJob extends Job { [ 'dataArray' => $argument['dataArray'], 'retryNo' => $argument['retryNo'] + 1, + 'lastRun' => time(), ] ); } } + + /** + * test if it is time for the next run + * + * @param array $argument + * @return bool + */ + protected function shouldRun($argument) { + return !isset($argument['lastRun']) || ((time() - $argument['lastRun']) > $this->interval); + } } |