Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing expiry time for PIREP API #356

Merged
merged 1 commit into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Console/Commands/DevCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Airline;
use App\Models\Pirep;
use App\Models\User;
use App\Repositories\AcarsRepository;
use App\Services\AirportService;
use App\Services\AwardService;
use App\Services\DatabaseService;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function handle()
'compile-assets' => 'compileAssets',
'db-attrs' => 'dbAttrs',
'list-awards' => 'listAwardClasses',
'live-flights' => 'liveFlights',
'manual-insert' => 'manualInsert',
'metar' => 'getMetar',
'reset-install' => 'resetInstall',
Expand Down Expand Up @@ -278,4 +280,12 @@ protected function resetInstall(): void

$this->info('Done!');
}

public function liveFlights(): void
{
$acarsRepo = app(AcarsRepository::class);
$flights = $acarsRepo->getPositions(setting('acars.live_time'))->toArray();

dd($flights);
}
}
16 changes: 6 additions & 10 deletions app/Http/Controllers/Api/PirepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,13 @@ protected function updateFares($pirep, Request $request)
*/
public function index()
{
$active = [];
$pireps = $this->acarsRepo->getPositions();
foreach ($pireps as $pirep) {
if (!$pirep->position) {
continue;
}

$active[] = $pirep;
}
$pireps = $this->acarsRepo
->getPositions(setting('acars.live_time'))
->filter(function ($pirep) {
return $pirep->position !== null;
});

return PirepResource::collection(collect($active));
return PirepResource::collection($pireps);
}

/**
Expand Down