From ff8d8371ad4f07a1c6bcce6184a71c43de80bd0b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 13 Dec 2023 12:13:20 +0100 Subject: [PATCH] fix: check queued deployments as well --- app/Console/Commands/Init.php | 2 +- app/Models/Application.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index 12d540aab..ec4d75484 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -99,7 +99,7 @@ private function cleanup_in_progress_application_deployments() // Cleanup any failed deployments try { - $halted_deployments = ApplicationDeploymentQueue::where('status', '==', 'in_progress')->get(); + $halted_deployments = ApplicationDeploymentQueue::where('status', '==', ApplicationDeploymentStatus::IN_PROGRESS)->where('status', '==', ApplicationDeploymentStatus::QUEUED)->get(); foreach ($halted_deployments as $deployment) { $deployment->status = ApplicationDeploymentStatus::FAILED->value; $deployment->save(); diff --git a/app/Models/Application.php b/app/Models/Application.php index e58d4a028..d3ddc4e43 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Enums\ApplicationDeploymentStatus; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; @@ -340,7 +341,7 @@ public function source() } public function isDeploymentInprogress() { - $deployments = ApplicationDeploymentQueue::where('application_id', $this->id)->where('status', 'in_progress')->count(); + $deployments = ApplicationDeploymentQueue::where('application_id', $this->id)->where('status', ApplicationDeploymentStatus::IN_PROGRESS)->where('status', ApplicationDeploymentStatus::QUEUED)->count(); if ($deployments > 0) { return true; }