ldc-mesbr-app/app/Console/Commands/ArchiveStatsCommand.php
2025-11-07 11:08:03 +01:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\ArchiveStatsJob;
use App\Models\ArchiveSite;
use App\Models\ArchiveStat;
use App\Statistique;
use Illuminate\Console\Command;
class ArchiveStatsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'uwil:stats:archive';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Archives mesbr stats';
/**
* Execute the console command.
*
* @return void
*/
public function handle(): void
{
$baseArchiveStatCount = ArchiveStat::count();
$baseStatCount = Statistique::count();
(new ArchiveStatsJob())->handle();
$this->info(sprintf(
'%s archive(s) created',
ArchiveStat::count() - $baseArchiveStatCount
));
$this->info(sprintf(
'%s stat(s) deleted',
$baseStatCount - Statistique::count()
));
$this->info('Stats archived 👌');
}
}