From 112e33783a6f71b7d201792c44e7cc66fb2e564a Mon Sep 17 00:00:00 2001 From: JoshuaMicallefYBSU <91457812+JoshuaMicallefYBSU@users.noreply.github.com> Date: Wed, 21 Aug 2024 18:28:52 +1000 Subject: [PATCH] Update ShanwickController --- .../Controllers/DiscordTestController.php | 4 +-- app/Jobs/ProcessShanwickController.php | 35 +++++++++++-------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/DiscordTestController.php b/app/Http/Controllers/DiscordTestController.php index c96f4189..fd7815ad 100644 --- a/app/Http/Controllers/DiscordTestController.php +++ b/app/Http/Controllers/DiscordTestController.php @@ -4,7 +4,7 @@ use Illuminate\Http\Request; use App\Services\DiscordClient; -use App\Jobs\ProcessSessionLogging; +use App\Jobs\ProcessShanwickController; class DiscordTestController extends Controller { @@ -26,7 +26,7 @@ public function EditTagTest() public function Job() { // Dispatch the job - $job = ProcessSessionLogging::dispatch(); + $job = ProcessShanwickController::dispatch(); // Call the handle method directly to get the result synchronously $result = $job->handle(); diff --git a/app/Jobs/ProcessShanwickController.php b/app/Jobs/ProcessShanwickController.php index 9bfa111e..fcce5274 100644 --- a/app/Jobs/ProcessShanwickController.php +++ b/app/Jobs/ProcessShanwickController.php @@ -283,21 +283,26 @@ public function handle() } } + // dd($non_czqo); + // Loop through all Non-CZQO Roster Members, and gather DB info from CZQO for those who have it. $get_vatsim_data = []; $use_gander_data = []; foreach($non_czqo as $eggx_controller){ - $controller = User::find($eggx_controller); - + $controller = User::where('id', $eggx_controller)->first(); + if($controller !== null){ - // Controller ID is Gander DB + // Controller ID is in Gander DB $use_gander_data[] = $eggx_controller; + // dd($controller); // Output the controller for debugging } else { // Controller has never logged into Gander $get_vatsim_data[] = $eggx_controller; } } + // dd($use_gander_data); + // Get Current Shanwick Details $shanwick_data = ShanwickController::all()->pluck('controller_cid'); $shanwick_data = $shanwick_data->toArray(); @@ -306,19 +311,19 @@ public function handle() // Update or Create Gander Shanwick Roster // Update from CZQO DB foreach($use_gander_data as $data1){ - $gander_controller = RosterMember::where('user_id', $data1)->first(); + $gander_controller = User::where('id', $data1)->first(); - // dd($gander_controller); - - ShanwickController::UpdateorCreate([ - 'controller_cid' => $data1, - 'name' => $gander_controller->user->fullName('FLC'), - 'rating' => $gander_controller->user->rating_short, - 'division' => $gander_controller->user->division_code, - 'division_name' => $gander_controller->user->division_name, - 'region_code' => $gander_controller->user->region_code, - 'region_name' => $gander_controller->user->region_name, - ]); + if($gander_controller !== null){ + ShanwickController::UpdateorCreate([ + 'controller_cid' => $data1, + 'name' => $gander_controller->fullName('FLC'), + 'rating' => $gander_controller->rating_short, + 'division' => $gander_controller->division_code, + 'division_name' => $gander_controller->division_name, + 'region_code' => $gander_controller->region_code, + 'region_name' => $gander_controller->region_name, + ]); + } } // Update from VATSIM API