Skip to content

Commit

Permalink
Merge pull request #324 from czqoocavatsim/JoshuaBranch
Browse files Browse the repository at this point in the history
Shanwick Roster Update Changes
  • Loading branch information
JoshuaMicallefYBSU authored Aug 21, 2024
2 parents 41120b0 + 08c5541 commit 060060c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/DiscordTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Http\Request;
use App\Services\DiscordClient;
use App\Jobs\ProcessSessionLogging;
use App\Jobs\ProcessShanwickController;

class DiscordTestController extends Controller
{
Expand All @@ -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();
Expand Down
35 changes: 20 additions & 15 deletions app/Jobs/ProcessShanwickController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 060060c

Please sign in to comment.