logRepository = $webhookModel->getLogRepository();
parent::__construct();
}
protected function configure(): void
{
$this->setName(static::COMMAND_NAME);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$logMaxLimit = (int) $this->coreParametersHelper->get('webhook_log_max', WebhookModel::WEBHOOK_LOG_MAX);
$webHookIds = $this->logRepository->getWebhooksBasedOnLogLimit($logMaxLimit);
$webhookCount = count($webHookIds);
$output->writeln("There is {$webhookCount} webhooks with logs more than defined limit.");
foreach ($webHookIds as $webHookId) {
$deletedLogCount = $this->logRepository->removeLimitExceedLogs($webHookId, $logMaxLimit);
$output->writeln(sprintf('%s logs deleted successfully for webhook id - %s', $deletedLogCount, $webHookId));
}
return Command::SUCCESS;
}
protected static $defaultDescription = 'Retains a rolling number of log records.';
}