style updates

This commit is contained in:
Mark Gregory
2026-07-24 14:59:44 +01:00
parent 24ab771cd3
commit dd23205d0b
482 changed files with 7173 additions and 1435 deletions
@@ -1,15 +1,30 @@
<?php
namespace Modules\Automation\Console;
use Illuminate\Console\Command;
use Modules\Automation\Models\Automation;
use Modules\Automation\Services\AutomationRunner;
final class DispatchScheduledAutomations extends Command
{
protected $signature='automation:dispatch-scheduled';
protected $description='Dispatch active automations whose next run time is due.';
protected $signature = 'automation:dispatch-scheduled';
protected $description = 'Dispatch active automations whose next run time is due.';
public function handle(AutomationRunner $runner): int
{
$count=0; Automation::query()->where('status','active')->where('trigger_type','schedule')->whereNotNull('next_run_at')->where('next_run_at','<=',now())->chunkById(100,function($items)use($runner,&$count){foreach($items as $automation){$runner->dispatch($automation,['scheduled_at'=>now()->toIso8601String()],'schedule');$interval=max(1,(int)($automation->trigger_config['interval_minutes']??60));$automation->update(['next_run_at'=>now()->addMinutes($interval)]);$count++;}});
$this->info("Dispatched {$count} scheduled automation(s)."); return self::SUCCESS;
$count = 0;
Automation::query()->where('status', 'active')->where('trigger_type', 'schedule')->whereNotNull('next_run_at')->where('next_run_at', '<=', now())->chunkById(100, function ($items) use ($runner, &$count) {
foreach ($items as $automation) {
$runner->dispatch($automation, ['scheduled_at' => now()->toIso8601String()], 'schedule');
$interval = max(1, (int) ($automation->trigger_config['interval_minutes'] ?? 60));
$automation->update(['next_run_at' => now()->addMinutes($interval)]);
$count++;
}
});
$this->info("Dispatched {$count} scheduled automation(s).");
return self::SUCCESS;
}
}