'Inventory Analytics', 'runOrderDeepLoad' => 'Order Deep Load', 'runProductScoring' => 'Product Scoring', 'runStockAudit' => 'Stock Audit', 'runPriceRecalculation' => 'Price Recalculation', 'runSummaryReport' => 'Summary Report', ]; public function __construct() { $this->activityStub = Workflow::newActivityStub( EloquentQueryActivityInterface::class, ActivityOptions::new() ->withStartToCloseTimeout(CarbonInterval::minutes(2)) ->withHeartbeatTimeout(CarbonInterval::seconds(30)) ->withRetryOptions( RetryOptions::new()->withMaximumAttempts(3) ) ); } public function runPipeline(array $simulationConfig = []): \Generator { $this->status = 'running'; try { foreach (self::STEPS as $method => $label) { $this->currentStep = $label; $result = yield $this->activityStub->$method($simulationConfig); $this->stepResults[$method] = [ 'label' => $label, 'queriesRun' => $result['queriesRun'] ?? 0, 'rowsAffected' => $result['rowsAffected'] ?? 0, 'executionTimeMs' => $result['executionTimeMs'] ?? 0, 'data' => $result['data'] ?? [], 'attempt' => $result['attempt'] ?? 1, ]; $this->totalQueriesRun += $result['queriesRun'] ?? 0; $this->totalRowsAffected += $result['rowsAffected'] ?? 0; $this->totalExecutionTimeMs += $result['executionTimeMs'] ?? 0; $this->completedSteps++; } } catch (\Throwable $e) { $this->status = 'failed'; throw $e; } $this->status = 'completed'; $this->currentStep = ''; return [ 'status' => 'completed', 'completedSteps' => $this->completedSteps, 'totalQueriesRun' => $this->totalQueriesRun, 'totalRowsAffected' => $this->totalRowsAffected, 'totalExecutionTimeMs' => $this->totalExecutionTimeMs, 'stepResults' => $this->stepResults, ]; } public function getProgress(): array { return [ 'status' => $this->status, 'currentStep' => $this->currentStep, 'completedSteps' => $this->completedSteps, 'totalSteps' => count(self::STEPS), 'stepResults' => $this->stepResults, 'totalQueriesRun' => $this->totalQueriesRun, 'totalRowsAffected' => $this->totalRowsAffected, 'totalExecutionTimeMs' => $this->totalExecutionTimeMs, ]; } }