Skip to content

Commit

Permalink
Update ShanwickController
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaMicallefYBSU committed Aug 21, 2024
1 parent 0c92f8c commit 112e337
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
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 112e337

Please sign in to comment.