mirror of
https://github.com/nextcloud/server.git
synced 2025-02-07 09:59:46 +00:00
![Git'Fellow](/assets/img/avatar_default.png)
Fix: psalm fix: bad file fix: bug chore: add batch chore: add batch chore: add batch fix: psalm
62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
namespace OCA\DAV\Migration;
|
|
|
|
use OCA\DAV\BackgroundJob\RefreshWebcalJob;
|
|
use OCP\BackgroundJob\IJobList;
|
|
use OCP\IDBConnection;
|
|
use OCP\Migration\IOutput;
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
class RefreshWebcalJobRegistrar implements IRepairStep {
|
|
|
|
/**
|
|
* FixBirthdayCalendarComponent constructor.
|
|
*
|
|
* @param IDBConnection $connection
|
|
* @param IJobList $jobList
|
|
*/
|
|
public function __construct(
|
|
private IDBConnection $connection,
|
|
private IJobList $jobList,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function getName() {
|
|
return 'Registering background jobs to update cache for webcal calendars';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function run(IOutput $output) {
|
|
$query = $this->connection->getQueryBuilder();
|
|
$query->select(['principaluri', 'uri'])
|
|
->from('calendarsubscriptions');
|
|
$stmt = $query->execute();
|
|
|
|
$count = 0;
|
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
|
$args = [
|
|
'principaluri' => $row['principaluri'],
|
|
'uri' => $row['uri'],
|
|
];
|
|
|
|
if (!$this->jobList->has(RefreshWebcalJob::class, $args)) {
|
|
$this->jobList->add(RefreshWebcalJob::class, $args);
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
$output->info("Added $count background jobs to update webcal calendars");
|
|
}
|
|
}
|