SchedulingTableSize.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\IDBConnection;
  9. use OCP\IL10N;
  10. use OCP\SetupCheck\ISetupCheck;
  11. use OCP\SetupCheck\SetupResult;
  12. class SchedulingTableSize implements ISetupCheck {
  13. public const MAX_SCHEDULING_ENTRIES = 50000;
  14. public function __construct(
  15. private IL10N $l10n,
  16. private IDBConnection $connection,
  17. ) {
  18. }
  19. public function getName(): string {
  20. return $this->l10n->t('Scheduling objects table size');
  21. }
  22. public function getCategory(): string {
  23. return 'database';
  24. }
  25. public function run(): SetupResult {
  26. $qb = $this->connection->getQueryBuilder();
  27. $qb->select($qb->func()->count('id'))
  28. ->from('schedulingobjects');
  29. $query = $qb->executeQuery();
  30. $count = $query->fetchOne();
  31. $query->closeCursor();
  32. if ($count > self::MAX_SCHEDULING_ENTRIES) {
  33. return SetupResult::warning(
  34. $this->l10n->t('You have more than %s rows in the scheduling objects table. Please run the expensive repair jobs via occ maintenance:repair --include-expensive.', [
  35. self::MAX_SCHEDULING_ENTRIES,
  36. ])
  37. );
  38. }
  39. return SetupResult::success(
  40. $this->l10n->t('Scheduling objects table size is within acceptable range.')
  41. );
  42. }
  43. }