diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index e518d43e7..143ff6d1e 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -317,7 +317,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue throw $e; } finally { $this->application_deployment_queue->update([ - 'finished_at' => now(), + 'finished_at' => Carbon::now()->toImmutable(), ]); if ($this->use_build_server) { diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 577c1f11a..0861c6bcc 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -331,6 +331,11 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue if ($this->team) { BackupCreated::dispatch($this->team->id); } + if ($this->backup_log) { + $this->backup_log->update([ + 'finished_at' => Carbon::now()->toImmutable(), + ]); + } } } diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php index 30fe6c5bc..05a4aa8de 100644 --- a/app/Jobs/DockerCleanupJob.php +++ b/app/Jobs/DockerCleanupJob.php @@ -8,6 +8,7 @@ use App\Models\DockerCleanupExecution; use App\Models\Server; use App\Notifications\Server\DockerCleanupFailed; use App\Notifications\Server\DockerCleanupSuccess; +use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Contracts\Queue\ShouldQueue; @@ -119,6 +120,12 @@ class DockerCleanupJob implements ShouldBeEncrypted, ShouldQueue } $this->server->team?->notify(new DockerCleanupFailed($this->server, 'Docker cleanup job failed with the following error: '.$e->getMessage())); throw $e; + } finally { + if ($this->execution_log) { + $this->execution_log->update([ + 'finished_at' => Carbon::now()->toImmutable(), + ]); + } } } } diff --git a/app/Jobs/ScheduledTaskJob.php b/app/Jobs/ScheduledTaskJob.php index 90a10f3e9..6c0c017e7 100644 --- a/app/Jobs/ScheduledTaskJob.php +++ b/app/Jobs/ScheduledTaskJob.php @@ -11,6 +11,7 @@ use App\Models\Service; use App\Models\Team; use App\Notifications\ScheduledTask\TaskFailed; use App\Notifications\ScheduledTask\TaskSuccess; +use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -131,6 +132,11 @@ class ScheduledTaskJob implements ShouldQueue throw $e; } finally { ScheduledTaskDone::dispatch($this->team->id); + if ($this->task_log) { + $this->task_log->update([ + 'finished_at' => Carbon::now()->toImmutable(), + ]); + } } } } diff --git a/database/migrations/2025_01_15_130416_create_docker_cleanup_executions_table.php b/database/migrations/2025_01_15_130416_create_docker_cleanup_executions_table.php index 1c24bfa3d..c96213125 100644 --- a/database/migrations/2025_01_15_130416_create_docker_cleanup_executions_table.php +++ b/database/migrations/2025_01_15_130416_create_docker_cleanup_executions_table.php @@ -19,6 +19,7 @@ return new class extends Migration $table->json('cleanup_log')->nullable(); $table->foreignId('server_id'); $table->timestamps(); + $table->timestamp('finished_at')->nullable(); }); } diff --git a/database/migrations/2025_01_16_130238_add_deployment_queue_finished_at.php b/database/migrations/2025_01_16_130238_add_deployment_queue_finished_at.php deleted file mode 100644 index 34b652ee0..000000000 --- a/database/migrations/2025_01_16_130238_add_deployment_queue_finished_at.php +++ /dev/null @@ -1,22 +0,0 @@ -timestamp('finished_at')->nullable(); - }); - } - - public function down() - { - Schema::table('application_deployment_queues', function (Blueprint $table) { - $table->dropColumn('finished_at'); - }); - } -}; diff --git a/database/migrations/2025_01_16_130238_add_finished_at_to_executions_tables.php b/database/migrations/2025_01_16_130238_add_finished_at_to_executions_tables.php new file mode 100644 index 000000000..0b78c8998 --- /dev/null +++ b/database/migrations/2025_01_16_130238_add_finished_at_to_executions_tables.php @@ -0,0 +1,38 @@ +timestamp('finished_at')->nullable(); + }); + Schema::table('scheduled_database_backup_executions', function (Blueprint $table) { + $table->timestamp('finished_at')->nullable(); + }); + + Schema::table('scheduled_task_executions', function (Blueprint $table) { + $table->timestamp('finished_at')->nullable(); + }); + + } + + public function down() + { + Schema::table('application_deployment_queues', function (Blueprint $table) { + $table->dropColumn('finished_at'); + }); + + Schema::table('scheduled_database_backup_executions', function (Blueprint $table) { + $table->dropColumn('finished_at'); + }); + + Schema::table('scheduled_task_executions', function (Blueprint $table) { + $table->dropColumn('finished_at'); + }); + } +}; diff --git a/resources/views/livewire/project/application/deployment/index.blade.php b/resources/views/livewire/project/application/deployment/index.blade.php index cc097e99a..37364ba12 100644 --- a/resources/views/livewire/project/application/deployment/index.blade.php +++ b/resources/views/livewire/project/application/deployment/index.blade.php @@ -66,8 +66,8 @@
Started: {{ formatDateInServerTimezone(data_get($deployment, 'created_at'), data_get($application, 'destination.server')) }} @if($deployment->status !== 'in_progress') -
Ended: {{ formatDateInServerTimezone(data_get($deployment, 'updated_at'), data_get($application, 'destination.server')) }} -
Duration: {{ calculateDuration(data_get($deployment, 'created_at'), data_get($deployment, 'updated_at')) }} +
Ended: {{ formatDateInServerTimezone(data_get($deployment, 'finished_at'), data_get($application, 'destination.server')) }} +
Duration: {{ calculateDuration(data_get($deployment, 'created_at'), data_get($deployment, 'finished_at')) }} @else
Running for: {{ calculateDuration(data_get($deployment, 'created_at'), now()) }} @endif diff --git a/resources/views/livewire/project/database/backup-executions.blade.php b/resources/views/livewire/project/database/backup-executions.blade.php index b42db371c..2f46a4657 100644 --- a/resources/views/livewire/project/database/backup-executions.blade.php +++ b/resources/views/livewire/project/database/backup-executions.blade.php @@ -38,8 +38,8 @@
Started: {{ formatDateInServerTimezone(data_get($execution, 'created_at'), $this->server()) }} @if(data_get($execution, 'status') !== 'running') -
Ended: {{ formatDateInServerTimezone(data_get($execution, 'updated_at'), $this->server()) }} -
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'updated_at')) }} +
Ended: {{ formatDateInServerTimezone(data_get($execution, 'finished_at'), $this->server()) }} +
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'finished_at')) }} @endif
diff --git a/resources/views/livewire/project/shared/scheduled-task/executions.blade.php b/resources/views/livewire/project/shared/scheduled-task/executions.blade.php index 63cbfd748..63be05a2d 100644 --- a/resources/views/livewire/project/shared/scheduled-task/executions.blade.php +++ b/resources/views/livewire/project/shared/scheduled-task/executions.blade.php @@ -46,8 +46,8 @@
Started: {{ formatDateInServerTimezone(data_get($execution, 'created_at', now()), data_get($task, 'application.destination.server') ?? data_get($task, 'service.destination.server')) }} @if(data_get($execution, 'status') !== 'running') -
Ended: {{ formatDateInServerTimezone(data_get($execution, 'updated_at'), data_get($task, 'application.destination.server') ?? data_get($task, 'service.destination.server')) }} -
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'updated_at')) }} +
Ended: {{ formatDateInServerTimezone(data_get($execution, 'finished_at'), data_get($task, 'application.destination.server') ?? data_get($task, 'service.destination.server')) }} +
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'finished_at')) }} @endif
diff --git a/resources/views/livewire/server/docker-cleanup-executions.blade.php b/resources/views/livewire/server/docker-cleanup-executions.blade.php index ea0aa7098..95460c62c 100644 --- a/resources/views/livewire/server/docker-cleanup-executions.blade.php +++ b/resources/views/livewire/server/docker-cleanup-executions.blade.php @@ -46,8 +46,8 @@
Started: {{ formatDateInServerTimezone(data_get($execution, 'created_at', now()), $server) }} @if(data_get($execution, 'status') !== 'running') -
Ended: {{ formatDateInServerTimezone(data_get($execution, 'updated_at'), $server) }} -
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'updated_at')) }} +
Ended: {{ formatDateInServerTimezone(data_get($execution, 'finished_at'), $server) }} +
Duration: {{ calculateDuration(data_get($execution, 'created_at'), data_get($execution, 'finished_at')) }} @endif