Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions apps/user_ldap/lib/Jobs/CleanUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
class CleanUp extends TimedJob {
/** @var int $limit amount of users that should be checked per run */
protected $limit = 50;
protected $limit;

/** @var int $defaultIntervalMin default interval in minutes */
protected $defaultIntervalMin = 51;
Expand All @@ -61,10 +61,10 @@ class CleanUp extends TimedJob {
/** @var Helper $ldapHelper */
protected $ldapHelper;

/** @var \OCA\User_LDAP\Mapping\UserMapping */
/** @var UserMapping */
protected $mapping;

/** @var \OCA\User_LDAP\User\DeletedUsersIndex */
/** @var DeletedUsersIndex */
protected $dui;

public function __construct() {
Expand Down Expand Up @@ -138,7 +138,7 @@ public function run($argument) {
if(!$this->isCleanUpAllowed()) {
return;
}
$users = $this->mapping->getList($this->getOffset(), $this->limit);
$users = $this->mapping->getList($this->getOffset(), $this->getChunkSize());
if(!is_array($users)) {
//something wrong? Let's start from the beginning next time and
//abort
Expand All @@ -156,7 +156,7 @@ public function run($argument) {
* @return bool
*/
public function isOffsetResetNecessary($resultCount) {
return $resultCount < $this->limit;
return $resultCount < $this->getChunkSize();
}

/**
Expand Down Expand Up @@ -222,7 +222,7 @@ private function getOffset() {
*/
public function setOffset($reset = false) {
$newOffset = $reset ? 0 :
$this->getOffset() + $this->limit;
$this->getOffset() + $this->getChunkSize();
$this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
}

Expand All @@ -231,6 +231,9 @@ public function setOffset($reset = false) {
* @return int
*/
public function getChunkSize() {
if($this->limit === null) {
$this->limit = (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobChunkSize', 50);
}
return $this->limit;
}

Expand Down