Add missing expiry time for PIREP API (#356)

This commit is contained in:
Nabeel S 2019-08-09 22:49:25 -04:00 committed by GitHub
parent 39fbdcb787
commit c1103afe8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -7,6 +7,7 @@ use App\Models\Acars;
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;
@ -55,6 +56,7 @@ class DevCommands extends Command
'compile-assets' => 'compileAssets',
'db-attrs' => 'dbAttrs',
'list-awards' => 'listAwardClasses',
'live-flights' => 'liveFlights',
'manual-insert' => 'manualInsert',
'metar' => 'getMetar',
'reset-install' => 'resetInstall',
@ -278,4 +280,12 @@ class DevCommands extends Command
$this->info('Done!');
}
public function liveFlights(): void
{
$acarsRepo = app(AcarsRepository::class);
$flights = $acarsRepo->getPositions(setting('acars.live_time'))->toArray();
dd($flights);
}
}

View File

@ -166,17 +166,13 @@ class PirepController extends Controller
*/
public function index()
{
$active = [];
$pireps = $this->acarsRepo->getPositions();
foreach ($pireps as $pirep) {
if (!$pirep->position) {
continue;
}
$pireps = $this->acarsRepo
->getPositions(setting('acars.live_time'))
->filter(function ($pirep) {
return $pirep->position !== null;
});
$active[] = $pirep;
}
return PirepResource::collection(collect($active));
return PirepResource::collection($pireps);
}
/**