2026-06-13 17:35:40 +03:30
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
2026-09-02 15:55:03 +03:30
|
|
|
use App\Services\DatabaseLogPruneService;
|
2026-06-13 17:35:40 +03:30
|
|
|
use App\Services\PriceSnapshotService;
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class PrunePriceSnapshotsCommand extends Command
|
|
|
|
|
{
|
|
|
|
|
protected $signature = 'prices:prune';
|
|
|
|
|
|
2026-09-02 15:55:03 +03:30
|
|
|
protected $description = 'Nightly prune: price history + bloating logs (31-day retention)';
|
2026-06-13 17:35:40 +03:30
|
|
|
|
2026-09-02 15:55:03 +03:30
|
|
|
public function handle(PriceSnapshotService $snapshots, DatabaseLogPruneService $logs): int
|
2026-06-13 17:35:40 +03:30
|
|
|
{
|
2026-09-02 15:55:03 +03:30
|
|
|
$stats = [
|
|
|
|
|
'prices' => $snapshots->pruneHistory(),
|
|
|
|
|
'logs' => $logs->pruneHistory(),
|
|
|
|
|
];
|
2026-06-13 17:35:40 +03:30
|
|
|
$this->info(json_encode($stats, JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
}
|