Skip to content

Commit

Permalink
Removed default yes option and use custom option
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmasahil committed Nov 21, 2024
1 parent 7ccbbd4 commit fef95c4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Command/AuditLogCleanupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,22 @@ public static function create(ContainerInterface $container) {
* @aliases tcl
* @description Cleans up audittrail logs older than the configured retention period.
*
* @option yes Skip confirmation and run the cleanup immediately.
* @option force-cleanup Skip confirmation and run the cleanup immediately.
*/
public function cleanupLogs($options = ['yes' => FALSE]) {
// Check if the user passed the --yes option
if (!$options['yes']) {
// If the -y/--yes flag isn't passed, ask for confirmation.
public function cleanupLogs($options = ['force-cleanup' => FALSE]) {
// Check if the user passed the --force-cleanup option
if (!$options['force-cleanup']) {
// If the force-cleanup flag isn't passed, ask for confirmation.
$confirmation = $this->confirmCleanup();
if (!$confirmation) {
$this->output()->writeln('<comment>Cleanup operation cancelled.</comment>');
return;
}
}

$config = $this->configFactory->get('tide_core.settings');
define('DEFAULT_LOG_RETENTION_DAYS', 30);
$log_retention_days = $config->get('log_retention_days') ?: DEFAULT_LOG_RETENTION_DAYS;

// Get current date and time
$current_time = new DateTime();
$current_time->sub(new DateInterval("P{$log_retention_days}D"));
Expand Down Expand Up @@ -106,4 +105,3 @@ private function optimizeDatabase() {
$this->output()->writeln("Database optimized to recover space.");
}
}

0 comments on commit fef95c4

Please sign in to comment.