1
0

CleanupJob.php 765 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\ContactsInteraction\BackgroundJob;
  8. use OCA\ContactsInteraction\Db\RecentContactMapper;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. use OCP\BackgroundJob\TimedJob;
  11. class CleanupJob extends TimedJob {
  12. public function __construct(
  13. ITimeFactory $time,
  14. private RecentContactMapper $mapper,
  15. ) {
  16. parent::__construct($time);
  17. $this->setInterval(24 * 60 * 60);
  18. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  19. }
  20. protected function run(mixed $argument): void {
  21. $time = $this->time->getDateTime();
  22. $time->modify('-7days');
  23. $this->mapper->cleanUp($time->getTimestamp());
  24. }
  25. }