mirror of
https://github.com/freescout-helpdesk/freescout.git
synced 2024-11-24 11:22:42 +01:00
Delete send logs older 6 months
This commit is contained in:
parent
c6fa18fe8d
commit
40cebf61c2
46
app/Console/Commands/CleanSendLog.php
Normal file
46
app/Console/Commands/CleanSendLog.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class CleanSendLog extends Command
|
||||||
|
{
|
||||||
|
const PERIOD = '-6 months';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'freescout:clean-send-log';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Delete old records from send log.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$logs = \App\SendLog::where('created_at', '<', \Carbon\Carbon::now()->modify(self::PERIOD))->delete();
|
||||||
|
|
||||||
|
$this->info('['.date('Y-m-d H:i:s').'] Deleted send logs: '.self::PERIOD);
|
||||||
|
}
|
||||||
|
}
|
@ -54,6 +54,9 @@ class Kernel extends ConsoleKernel
|
|||||||
->everyMinute()
|
->everyMinute()
|
||||||
->withoutOverlapping();
|
->withoutOverlapping();
|
||||||
|
|
||||||
|
$schedule->command('freescout:clean-send-log')
|
||||||
|
->monthly();
|
||||||
|
|
||||||
// Logs monitoring.
|
// Logs monitoring.
|
||||||
$alert_logs_period = config('app.alert_logs_period');
|
$alert_logs_period = config('app.alert_logs_period');
|
||||||
if (config('app.alert_logs') && $alert_logs_period) {
|
if (config('app.alert_logs') && $alert_logs_period) {
|
||||||
|
Loading…
Reference in New Issue
Block a user