diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 8184e34a..b65aa9b4 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -100,7 +100,7 @@ protected function schedule(Schedule $schedule) $schedule->job(new ProcessSoloCertExpiryWarnings())->daily(); // Shanwick Controller Roster Update - $schedule->job(new ProcessShanwickController())->dailyAt('07:05'); + $schedule->job(new ProcessShanwickController())->dailyAt('08:35'); //Training/OTS session reminders $schedule->job(new ProcessSessionReminders())->daily(); 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