a bit of progress
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Game;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\Game\CooldownService;
|
||||
use App\Models\Cooldown;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ProcessCooldowns extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'game:process-cooldowns';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Process and clean up expired cooldowns';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(CooldownService $cooldownService): int
|
||||
{
|
||||
$this->info('Processing cooldowns...');
|
||||
|
||||
// Delete expired cooldowns
|
||||
$maxAge = now()->subHours(24); // Keep cooldowns for 24 hours max
|
||||
$deleted = Cooldown::where('last_action_at', '<', $maxAge)->delete();
|
||||
|
||||
$this->info("Deleted {$deleted} expired cooldown records.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user