Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
mufassilyasir committed Jun 20, 2023
1 parent 79153f3 commit bd969b5
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 1,720 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function schedule(Schedule $schedule)
//Tell Discord all about it
$discord = new DiscordClient();
$discord->sendMessage(753086414811562014, 'Sent '.$count.' two-week warning inactivity emails');
})->cron('00 19 16 MAR,JUN,SEP,DEC *'); // 2 weeks before end of quarter
})->cron('00 00 16 MAR,JUN,SEP,DEC *'); // 2 weeks before end of quarter

// 1 week
$schedule->call(function () {
Expand Down
34 changes: 6 additions & 28 deletions app/Http/Controllers/PrimaryViewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use App\Models\Events\Event;
use Illuminate\Http\Request;
use App\Models\Network\SessionLog;
use Atymic\Twitter\Facade\Twitter;
use App\Models\Roster\RosterMember;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use App\Models\Settings\RotationImage;
use App\Models\Publications\AtcResource;
use App\Models\News\HomeNewControllerCert;
use App\Services\VATSIMClient;

class PrimaryViewsController extends Controller
{
Expand All @@ -34,24 +34,13 @@ public function home(Request $request)
//Top controllers
$topControllers = RosterMember::where('monthly_hours', '>', 0)->get()->sortByDesc('monthly_hours')->take(3);

//Twitter
$tweets = Cache::remember('twitter.timeline', 86400, function () {
try {
return Twitter::getUserTimeline(['screen_name' => 'ganderocavatsim', 'count' => 3, 'response_format' => 'json']);
} catch (\Exception $ex) {
return null;
}
});

$tweets = json_decode($tweets);

//CTP Mode?
$ctpMode = false;
if (config('app.ctp_home_page')) {
$ctpMode = true;
}

return view('index', compact('controllers', 'news', 'certifications', 'nextEvent', 'topControllers', 'tweets', 'ctpMode'));
return view('index', compact('controllers', 'news', 'certifications', 'nextEvent', 'topControllers', 'ctpMode'));
}

/*
Expand All @@ -60,21 +49,10 @@ public function home(Request $request)
public function map()
{
//VATSIM online controllers
$vatsim = new \Vatsimphp\VatsimData();
$vatsim->setConfig('cacheOnly', false);
$ganderControllers = [];
$shanwickControllers = [];
$controllerOnline = false;
$planes = null;
if ($vatsim->loadData()) {
$ganderControllers = $vatsim->searchCallsign('CZQX_');
$shanwickControllers = $vatsim->searchCallsign('EGGX_');
$controllers = array_merge($ganderControllers->toArray(), $shanwickControllers->toArray());
if (count($controllers) > 1) {
$controllerOnline = true;
}
$planes = $vatsim->getPilots()->toArray();
}
$controllerOnline = SessionLog::whereNull('session_end')->exists();

$vatsim = new VATSIMClient();
$planes = $vatsim->getPilots();

return view('pilots.map', compact('planes', 'controllerOnline'));
}
Expand Down
11 changes: 10 additions & 1 deletion app/Jobs/ProcessRosterInactivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Illuminate\Support\Facades\Notification;
use App\Notifications\Roster\RosterStatusChanged;
use App\Notifications\Roster\RemovedFromRoster;
use Illuminate\Support\Facades\Log;
use App\Services\DiscordClient;

class ProcessRosterInactivity implements ShouldQueue
{
Expand Down Expand Up @@ -60,6 +60,15 @@ public function handle()
if ($rosterMember->currency < 6.0) {
$rosterMember->active = false;
$rosterMember->save();

$discord = new DiscordClient();
$discord_user_id = $rosterMember->user->discord_user_id;
if ($discord_user_id && $rosterMember->user->member_of_czqo){
$discord->removeRole($discord_user_id, 482819739996127259);
$discord->assignRole($discord_user_id, 482835389640343562);
}
$rosterMember->user->removeRole('Certified Controller');
$rosterMember->user->assignRole('Guest');
Notification::send($rosterMember->user, new RosterStatusChanged($rosterMember));
}
}elseif (!$rosterMember->active) {
Expand Down
9 changes: 9 additions & 0 deletions app/Services/VATSIMClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ public function searchCallsign($callsign, $precise)

return $controllers;
}

public function getPilots()
{
$data = Cache::remember('vatsimdatapilots', 60*60*1, function () {
return $this->getVATSIMData();
});

return $data->pilots;
}
}
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^8.0",
"asantibanez/livewire-calendar": "dev-master",
"atymic/twitter": "^3.2",
"php": "^8.2",
"barryvdh/laravel-dompdf": "^2.0",
"bugsnag/bugsnag-laravel": "^2.0",
"erusev/parsedown": "^1.7",
Expand All @@ -30,7 +28,6 @@
"misterphilip/maintenance-mode": "~2.0",
"mofodojodino/profanity-filter": "^1.3",
"sentry/sentry-laravel": "^3.4",
"skymeyer/vatsimphp": "^2.0",
"spatie/laravel-activitylog": "^4.7",
"spatie/laravel-cookie-consent": "^3.2",
"spatie/laravel-html": "^3.2",
Expand Down
Loading

0 comments on commit bd969b5

Please sign in to comment.