- Added new automation-related routes and controllers for managing automations. - Introduced automation nodes in the UI with distinct styles and interactions. - Updated sidebar to include navigation for automations. - Enhanced post creation logic to support automation metadata. - Refactored content type and platform enums into types for better type safety. - Added localization for automation-related terms in English, Spanish, and Portuguese. - Improved error handling in various components to accommodate new features.
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Console\Commands\Automation;
|
|
|
|
use App\Actions\Automation\Run\AdvanceAutomationRun;
|
|
use App\Enums\Automation\Run\Status;
|
|
use App\Models\AutomationRun;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
#[Signature('automation:process-delays')]
|
|
#[Description('Wake up runs that finished their delay window')]
|
|
class ProcessAutomationDelays extends Command
|
|
{
|
|
public function handle(AdvanceAutomationRun $advance): int
|
|
{
|
|
AutomationRun::query()
|
|
->where('status', Status::Waiting)
|
|
->where('next_action_at', '<=', now())
|
|
->lockForUpdate()
|
|
->chunkById(50, function ($runs) use ($advance) {
|
|
DB::transaction(function () use ($runs, $advance) {
|
|
foreach ($runs as $run) {
|
|
$run->update([
|
|
'status' => Status::Running,
|
|
'next_action_at' => null,
|
|
]);
|
|
$advance($run, $run->current_node_id);
|
|
}
|
|
});
|
|
});
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|