1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace OCA\DAV\Migration;
- use OCP\BackgroundJob\IJobList;
- use OCP\IConfig;
- use OCP\IDBConnection;
- use OCP\Migration\IOutput;
- use OCP\Migration\IRepairStep;
- class BuildCalendarSearchIndex implements IRepairStep {
- public function __construct(
- private IDBConnection $db,
- private IJobList $jobList,
- private IConfig $config,
- ) {
- }
-
- public function getName() {
- return 'Registering building of calendar search index as background job';
- }
-
- public function run(IOutput $output) {
-
- if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') {
- $output->info('Repair step already executed');
- return;
- }
- $query = $this->db->getQueryBuilder();
- $query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
- ->from('calendarobjects');
- $result = $query->executeQuery();
- $maxId = (int)$result->fetchOne();
- $result->closeCursor();
- $output->info('Add background job');
- $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [
- 'offset' => 0,
- 'stopAt' => $maxId
- ]);
-
- $this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes');
- }
- }
|