From 1c11a35b1edd5d4f8e26f6d014ecf8c8a7b66320 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Tue, 20 Feb 2024 20:56:54 -0500 Subject: [PATCH 1/2] added fix result statuses command --- .../Maintenance/FixResultStatuses.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 app/Console/Commands/Maintenance/FixResultStatuses.php diff --git a/app/Console/Commands/Maintenance/FixResultStatuses.php b/app/Console/Commands/Maintenance/FixResultStatuses.php new file mode 100644 index 000000000..67d0fbb7a --- /dev/null +++ b/app/Console/Commands/Maintenance/FixResultStatuses.php @@ -0,0 +1,70 @@ +newLine(); + + $this->info('This will check each result and correct the status to "completed" or "failed" based on the data column.'); + $this->info('📖 Read the docs: https://docs.speedtest-tracker.dev/other/commands'); + + if (! $this->confirm('Do you want to continue?')) { + return Command::FAILURE; + } + + /** + * Update completed status + */ + DB::table('results') + ->where(function (Builder $query) { + $query->where('service', '=', 'ookla') + ->whereNull('data->level') + ->whereNull('data->message'); + }) + ->update([ + 'status' => ResultStatus::Completed, + ]); + + /** + * Update failed status. + */ + DB::table('results') + ->where(function (Builder $query) { + $query->where('service', '=', 'ookla') + ->where('data->level', '=', 'error') + ->whereNotNull('data->message'); + }) + ->update([ + 'status' => ResultStatus::Failed, + ]); + + $this->line("✅ finished!"); + + return Command::SUCCESS; + } +} From 02550fea14c6394834cbadc2684e15274e008666 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Tue, 20 Feb 2024 21:00:19 -0500 Subject: [PATCH 2/2] code quality --- app/Console/Commands/Maintenance/FixResultStatuses.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Maintenance/FixResultStatuses.php b/app/Console/Commands/Maintenance/FixResultStatuses.php index 67d0fbb7a..6089bef3f 100644 --- a/app/Console/Commands/Maintenance/FixResultStatuses.php +++ b/app/Console/Commands/Maintenance/FixResultStatuses.php @@ -63,7 +63,7 @@ public function handle() 'status' => ResultStatus::Failed, ]); - $this->line("✅ finished!"); + $this->line('✅ finished!'); return Command::SUCCESS; }