public function getTest() { // Save the PIREP and dispatch the event $pirep = new Pirep(); $pirep->booking_id = 15; $pirep->landing_rate = -150; $pirep->fuel_used = 1000; $pirep->load = 0; $pirep->log = "smartCARS version 2.0.50.0, 2015/2/10 UTC[07:44:59 PM] Preflight started, flying offline[07:44:59 PM] Flying Boeing 737-8ASNGX Ryanair Winglets[07:44:59 PM] Engine 1 is on[07:44:59 PM] Engine 2 is on[07:45:11 PM] Flaps set to position 1[07:45:18 PM] Flaps set to position 2[07:45:22 PM] Flaps set to position 3[07:45:26 PM] Flaps set to position 4[07:45:30 PM] Flaps set to position 5[07:45:32 PM] Flaps set to position 6[07:45:36 PM] Flaps set to position 7[07:45:40 PM] Flaps set to position 8[07:45:51 PM] Pushing back with 10883 lb of fuel[07:45:51 PM] Taxiing to runway[07:45:56 PM] Taking off[07:46:08 PM] Climbing, pitch: 6, roll: 0, 138 kts[07:46:13 PM] Gear lever raised at 418 ft at 153 kts[07:46:23 PM] Flaps set to position 7 at 1053 ft at 157 kts[07:46:28 PM] Flaps set to position 6 at 1328 ft at 160 kts[07:46:31 PM] Flaps set to position 5 at 1530 ft at 161 kts[07:46:34 PM] Flaps set to position 4 at 1641 ft at 161 kts[07:46:37 PM] Flaps set to position 3 at 1780 ft at 162 kts[07:46:41 PM] Flaps set to position 2 at 1907 ft at 163 kts[07:46:45 PM] Flaps set to position 1 at 1993 ft at 164 kts[07:46:52 PM] Flaps set to position 0 at 2004 ft at 166 kts[07:46:54 PM] Cruising at 1500ft, pitch: 5, 171 kts[07:46:57 PM] Descending[07:46:57 PM] Approaching[07:46:57 PM] Final approach, 171 kts[07:48:27 PM] Go around conditions met[07:48:41 PM] Standard final approach conditions met[07:49:25 PM] Gear lever lowered at 1266 ft at 168 kts[07:49:29 PM] Flaps set to position 7 at 1215 ft at 165 kts[07:49:46 PM] Go around conditions met[07:49:47 PM] Flaps set to position 3 at 1238 ft at 156 kts[07:49:51 PM] Flaps set to position 4 at 1335 ft at 156 kts[07:49:54 PM] Flaps set to position 5 at 1401 ft at 156 kts[07:49:57 PM] Flaps set to position 6 at 1445 ft at 157 kts[07:50:00 PM] Flaps set to position 7 at 1545 ft at 156 kts[07:50:05 PM] Flaps set to position 8 at 1722 ft at 157 kts[07:50:11 PM] Standard final approach conditions met[07:51:56 PM] Touched down at -93 fpm, gear lever: down, pitch: 3, roll: -1, 114 kts[07:52:08 PM] Landed in 1643 ft, fuel: 10076 lb, weight: 101376 lb[07:52:08 PM] Taxiing to gate[07:52:11 PM] The flight may now be ended[07:52:11 PM] Taxi time was less than 15 seconds[07:52:11 PM] Arrived, flight duration: 00:05[07:52:16 PM] Engine 2 is off[07:52:17 PM] Engine 1 is off"; $pirep->save(); $pilot = SmartCARS_Session::where('pilot_id', '=', 2)->where('sessionid', '=', 'kJa4ydo2M6LBzEDzqVELHJ8VciDQwIZWeNFCYW9JTUOjCfHlIfu1r0vhb5w3aQzm')->first()->pilot; Event::fire(new PirepWasFiled($pirep, $pilot)); }
public function getRescoreAll() { $pireps = Pirep::all(); foreach ($pireps as $pirep) { Event::fire(new PirepWasProcessed($pirep, $pirep->booking->pilot, true)); } return redirect('/staff/pireps')->with('flash', 'All PIREPs have been submitted for rescoring'); }
public function getIndex() { $pireps = Pirep::fromPilot()->orderBy('created_at', 'desc')->get(); $pireps->load(['booking' => function ($query) { $query->withTrashed(); // Include "deleted" bookings }, 'booking.route' => function ($query) { $query->withTrashed(); // Include "deleted" routes }, 'booking.pilot.user']); return view('pireps/list', ['pireps' => $pireps]); }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->call(function () { $pirepsByUser = null; Pirep::where('pirep_data', '!=', '{"jumpseat":true}')->chunk(100, function ($pirepsChunk) use(&$pirepsByUser) { // TODO Improve this detection... $pirepsByUser = $pirepsChunk->groupBy(function ($item, $key) { return $item->booking->pilot->id; }); }); // Most Points $pointsPirepsByUser = $pirepsByUser->sortByDesc(function (&$item, $key) { $totalPoints = 0; foreach ($item as $pirep) { $totalPoints += $pirep->points; } $item->totalPoints = $totalPoints; return $totalPoints; }); // Most Hours $timePirepsByUser = $pirepsByUser->sortByDesc(function (&$item, $key) { $totalSeconds = 0; foreach ($item as $pirep) { $totalSeconds += $pirep->landing_time->getTimestamp() - $pirep->departure_time->getTimestamp(); } $item->totalInterval = Carbon::now()->addSeconds($totalSeconds); return $totalSeconds; }); // Most PIREPs $countPirepsByUser = $pirepsByUser->sortByDesc(function ($item, $key) { return count($item); }); Cache::forever('RYR:Leaderboards:Global', ['pirepCounts' => $countPirepsByUser->slice(0, 30), 'pirepHours' => $timePirepsByUser->slice(0, 30), 'pirepPoints' => $pointsPirepsByUser->slice(0, 30)]); // TODO: Make this run for each airline })->hourly(); }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { // Count airline PIREPs $totalPirepsCount = Pirep::fromAirline()->count(); $view->with('airlinePirepsCount', $totalPirepsCount); }
private function handleFilePirep($request) { if ($this->handleVerifySession($request) == 'AUTH_FAILED') { return "AUTH_FAILED"; } // Save the PIREP and dispatch the event $pirep = new Pirep(); $pirep->provided_route = $request->input('route'); $pirep->comments = $request->input('comments'); $pirep->log = $request->input('log'); $pirep->booking_id = $request->input('bidid'); $pirep->landing_rate = $request->input('landingrate'); $pirep->fuel_used = $request->input('fuelused'); $pirep->load = $request->input('load'); $pirep->points = 0; $pirep->acars_id = 1; $pirep->pirep_data = []; $pirep->save(); $pilot = SmartCARS_Session::where('pilot_id', '=', $request->input('dbid'))->where('sessionid', '=', $request->input('sessionid'))->first()->pilot; Event::fire(new PirepWasFiled($pirep, $pilot)); return "SUCCESS"; }
public function getDoJumpseat(Route $route) { // todo: VALIDATE! $pilot = PilotRepository::getCurrentPilot(); // Save this jumpseat so we can track them! $booking = new Booking(); $booking->pilot()->associate($pilot); $booking->route()->associate($route); $booking->aircraft_id = null; // This indicates a jumpseat booking $booking->callsign = 'JUMPSEAT'; // This also indicates a jumpseat booking $booking->save(); $booking->delete(); // Put in a dummy PIREP $pirep = new Pirep(); $pirep->booking()->associate($booking); $pirep->pirep_data = ['jumpseat' => true]; $pirep->status = 'complete'; $pirep->points = 0; $pirep->landing_rate = 0; $pirep->fuel_used = 0; $pirep->load = 0; $pirep->save(); $pilot->location()->associate($route->arrivalAirport); $pilot->save(); return redirect('/flights'); }