Implement academy analytics, billing, and web stories updates
This commit is contained in:
27
app/Console/Commands/AcademyAnalyticsPruneEventsCommand.php
Normal file
27
app/Console/Commands/AcademyAnalyticsPruneEventsCommand.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\AcademyEvent;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
final class AcademyAnalyticsPruneEventsCommand extends Command
|
||||
{
|
||||
protected $signature = 'academy:analytics-prune-events {--days=180}';
|
||||
|
||||
protected $description = 'Delete old raw Academy analytics events while keeping daily rollups';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$days = max(1, (int) $this->option('days'));
|
||||
$deleted = AcademyEvent::query()
|
||||
->where('occurred_at', '<', now()->subDays($days)->startOfDay())
|
||||
->delete();
|
||||
|
||||
$this->info(sprintf('Pruned %d Academy analytics event(s).', $deleted));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user