feat: tick planner, delivery job, scheduler and purge
Also: test uses disabled channels instead of deleting them (FK cascade); ChannelRegistry no longer final so tests can extend it (controller ruling). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
26
core/app/Console/Commands/PurgeCommand.php
Normal file
26
core/app/Console/Commands/PurgeCommand.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\EventState;
|
||||
use App\Models\Event;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PurgeCommand extends Command
|
||||
{
|
||||
protected $signature = 'hado:purge';
|
||||
|
||||
protected $description = 'Удаляет терминальные события старше HADO_RETENTION_DAYS';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$terminal = array_map(fn (EventState $s) => $s->value, array_filter(EventState::cases(), fn (EventState $s) => $s->isTerminal()));
|
||||
$cutoff = CarbonImmutable::now()->subDays((int) config('hado.retention_days'));
|
||||
|
||||
$deleted = Event::whereIn('state', $terminal)->where('updated_at', '<', $cutoff)->delete();
|
||||
$this->info("Удалено событий: {$deleted}");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user