mirror of
https://github.com/nextcloud/server.git
synced 2024-12-29 00:18:42 +00:00
54ec472d9a
Signed-off-by: provokateurin <kate@provokateurin.de>
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
|
|
namespace OC\TextProcessing;
|
|
|
|
use OC\TextProcessing\Db\TaskMapper;
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
use OCP\BackgroundJob\TimedJob;
|
|
use OCP\DB\Exception;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class RemoveOldTasksBackgroundJob extends TimedJob {
|
|
public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 7; // 1 week
|
|
|
|
public function __construct(
|
|
ITimeFactory $timeFactory,
|
|
private TaskMapper $taskMapper,
|
|
private LoggerInterface $logger,
|
|
) {
|
|
parent::__construct($timeFactory);
|
|
$this->setInterval(60 * 60 * 24);
|
|
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
|
|
}
|
|
|
|
/**
|
|
* @param mixed $argument
|
|
* @inheritDoc
|
|
*/
|
|
protected function run($argument) {
|
|
try {
|
|
$this->taskMapper->deleteOlderThan(self::MAX_TASK_AGE_SECONDS);
|
|
} catch (Exception $e) {
|
|
$this->logger->warning('Failed to delete stale language model tasks', ['exception' => $e]);
|
|
}
|
|
}
|
|
}
|