From 12f80406c9b02eee831568a488ec8b30c5ecd215 Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Wed, 7 Feb 2024 00:30:17 +0900 Subject: [PATCH 1/6] Set Visible to True Only When Owned By The Core --- app/Cron/Nightly/SetActiveFlights.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index 9b6b10bbf..2cf0970b6 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -44,8 +44,10 @@ public function checkFlights(): void continue; } - // Set to visible by default - $flight->visible = true; + // Set to visible by default if not owned by a module + if ($flight['owner_type'] === null) { + $flight->visible = true; + } // dates aren't set, so just save if there were any changes above // and move onto the next one From fbace9d3bd0e6560af36b1a2b8c6b8f3f2297c5d Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Wed, 7 Feb 2024 00:36:48 +0900 Subject: [PATCH 2/6] Better Syntax --- app/Cron/Nightly/SetActiveFlights.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index 2cf0970b6..2930f8bc1 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -45,7 +45,7 @@ public function checkFlights(): void } // Set to visible by default if not owned by a module - if ($flight['owner_type'] === null) { + if (blank($flight->owner_type)) { $flight->visible = true; } From 1754157f68815e16953657158c40501baf8c3b52 Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Tue, 23 Jul 2024 13:31:50 +0900 Subject: [PATCH 3/6] Ammended based on Dispo's Feedback --- app/Cron/Nightly/SetActiveFlights.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index 2930f8bc1..cd278bd56 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -34,7 +34,7 @@ public function handle(CronNightly $event): void public function checkFlights(): void { $today = Carbon::now('UTC'); - $flights = Flight::all(); + $flights = Flight::where('active', 1)->whereNull('owner_type')->get(); /** * @var Flight $flight @@ -43,12 +43,7 @@ public function checkFlights(): void if (!$flight->active) { continue; } - - // Set to visible by default if not owned by a module - if (blank($flight->owner_type)) { - $flight->visible = true; - } - + // dates aren't set, so just save if there were any changes above // and move onto the next one if ($flight->start_date === null || $flight->end_date === null) { From 5730a7a8acb35adc403fe4104439535ae21b25b9 Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Mon, 29 Jul 2024 10:22:38 +0900 Subject: [PATCH 4/6] Applied changes based on feedback. --- app/Cron/Nightly/SetActiveFlights.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index cd278bd56..5dfaf336b 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -7,6 +7,7 @@ use App\Models\Enums\Days; use App\Models\Flight; use Carbon\Carbon; +use App\Models\Flight; use Illuminate\Support\Facades\Log; /** @@ -34,7 +35,7 @@ public function handle(CronNightly $event): void public function checkFlights(): void { $today = Carbon::now('UTC'); - $flights = Flight::where('active', 1)->whereNull('owner_type')->get(); + $flights = Flight::where('owner_type', Flight::class)->get(); /** * @var Flight $flight @@ -43,7 +44,9 @@ public function checkFlights(): void if (!$flight->active) { continue; } - + // Set visible default + $flight->visible = true; + // dates aren't set, so just save if there were any changes above // and move onto the next one if ($flight->start_date === null || $flight->end_date === null) { From 4766c2f9f3ba37e492cd9494b8377aa8191b6a63 Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Mon, 29 Jul 2024 10:25:57 +0900 Subject: [PATCH 5/6] Corrected Logic. Corrected database seeder for Flights --- app/Cron/Nightly/SetActiveFlights.php | 2 +- app/Database/factories/FlightFactory.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index 5dfaf336b..e8061b80f 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -35,7 +35,7 @@ public function handle(CronNightly $event): void public function checkFlights(): void { $today = Carbon::now('UTC'); - $flights = Flight::where('owner_type', Flight::class)->get(); + $flights = Flight::where('active', 1)->whereNull('owner_type')->get(); /** * @var Flight $flight diff --git a/app/Database/factories/FlightFactory.php b/app/Database/factories/FlightFactory.php index 203059418..7b9bdf9df 100644 --- a/app/Database/factories/FlightFactory.php +++ b/app/Database/factories/FlightFactory.php @@ -55,7 +55,7 @@ public function definition(): array DateTime::ATOM ), 'updated_at' => static fn (array $flight) => $flight['created_at'], - 'owner_type' => Flight::class, + 'owner_type' => null, 'owner_id' => null, ]; } From 7b3aab4e37fc81bf751f023043f27a9f853d2889 Mon Sep 17 00:00:00 2001 From: Taylor Broad Date: Mon, 29 Jul 2024 19:29:51 +0900 Subject: [PATCH 6/6] Fix for style-cl --- app/Cron/Nightly/SetActiveFlights.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Cron/Nightly/SetActiveFlights.php b/app/Cron/Nightly/SetActiveFlights.php index e8061b80f..3573ce821 100644 --- a/app/Cron/Nightly/SetActiveFlights.php +++ b/app/Cron/Nightly/SetActiveFlights.php @@ -7,7 +7,6 @@ use App\Models\Enums\Days; use App\Models\Flight; use Carbon\Carbon; -use App\Models\Flight; use Illuminate\Support\Facades\Log; /**