aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php')
-rw-r--r--apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php55
1 files changed, 38 insertions, 17 deletions
diff --git a/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php b/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php
index 9a688970597..231749521be 100644
--- a/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php
+++ b/apps/dav/lib/Migration/BuildSocialSearchIndexBackgroundJob.php
@@ -1,12 +1,8 @@
<?php
-
-declare(strict_types=1);
-
/**
* @copyright 2020 Matthias Heinisch <nextcloud@matthiasheinisch.de>
*
* @author call-me-matt <nextcloud@matthiasheinisch.de>
- * @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
@@ -26,22 +22,47 @@ declare(strict_types=1);
*/
namespace OCA\DAV\Migration;
+use OC\BackgroundJob\QueuedJob;
use OCA\DAV\CardDAV\CardDavBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
-use OCP\BackgroundJob\QueuedJob;
use OCP\IDBConnection;
-use Psr\Log\LoggerInterface;
+use OCP\ILogger;
class BuildSocialSearchIndexBackgroundJob extends QueuedJob {
- public function __construct(
- private IDBConnection $db,
- private CardDavBackend $davBackend,
- private LoggerInterface $logger,
- private IJobList $jobList,
- ITimeFactory $timeFactory,
- ) {
- parent::__construct($timeFactory);
+
+ /** @var IDBConnection */
+ private $db;
+
+ /** @var CardDavBackend */
+ private $davBackend;
+
+ /** @var ILogger */
+ private $logger;
+
+ /** @var IJobList */
+ private $jobList;
+
+ /** @var ITimeFactory */
+ private $timeFactory;
+
+ /**
+ * @param IDBConnection $db
+ * @param CardDavBackend $davBackend
+ * @param ILogger $logger
+ * @param IJobList $jobList
+ * @param ITimeFactory $timeFactory
+ */
+ public function __construct(IDBConnection $db,
+ CardDavBackend $davBackend,
+ ILogger $logger,
+ IJobList $jobList,
+ ITimeFactory $timeFactory) {
+ $this->db = $db;
+ $this->davBackend = $davBackend;
+ $this->logger = $logger;
+ $this->jobList = $jobList;
+ $this->timeFactory = $timeFactory;
}
public function run($arguments) {
@@ -69,7 +90,7 @@ class BuildSocialSearchIndexBackgroundJob extends QueuedJob {
* @return int
*/
private function buildIndex($offset, $stopAt) {
- $startTime = $this->time->getTime();
+ $startTime = $this->timeFactory->getTime();
// get contacts with social profiles
$query = $this->db->getQueryBuilder();
@@ -78,7 +99,7 @@ class BuildSocialSearchIndexBackgroundJob extends QueuedJob {
->orderBy('id', 'ASC')
->where($query->expr()->like('carddata', $query->createNamedParameter('%SOCIALPROFILE%')))
->setMaxResults(100);
- $social_cards = $query->executeQuery()->fetchAll();
+ $social_cards = $query->execute()->fetchAll();
if (empty($social_cards)) {
return $stopAt;
@@ -90,7 +111,7 @@ class BuildSocialSearchIndexBackgroundJob extends QueuedJob {
$this->davBackend->updateCard($contact['addressbookid'], $contact['uri'], $contact['carddata']);
// stop after 15sec (to be continued with next chunk)
- if (($this->time->getTime() - $startTime) > 15) {
+ if (($this->timeFactory->getTime() - $startTime) > 15) {
break;
}
}