diff --git a/app/Cron/Hourly/RemoveExpiredLiveFlights.php b/app/Cron/Hourly/RemoveExpiredLiveFlights.php new file mode 100644 index 000000000..791fa837a --- /dev/null +++ b/app/Cron/Hourly/RemoveExpiredLiveFlights.php @@ -0,0 +1,33 @@ +subHours(setting('acars.live_time')); + Pirep::whereDate('created_at', '<', $date) + ->where('state', PirepState::IN_PROGRESS) + ->delete(); + } +} diff --git a/app/Events/CronHourly.php b/app/Events/CronHourly.php index 08bd0c3f0..41f904bf3 100644 --- a/app/Events/CronHourly.php +++ b/app/Events/CronHourly.php @@ -13,7 +13,7 @@ class CronHourly use Dispatchable, SerializesModels; /** - * CronNightly constructor. + * CronHourly constructor. */ public function __construct() { diff --git a/app/Http/Controllers/Api/AcarsController.php b/app/Http/Controllers/Api/AcarsController.php index 56280f976..155bf7403 100644 --- a/app/Http/Controllers/Api/AcarsController.php +++ b/app/Http/Controllers/Api/AcarsController.php @@ -69,7 +69,7 @@ protected function checkCancelled(Pirep $pirep) */ public function index(Request $request) { - $pireps = $this->acarsRepo->getPositions(); + $pireps = $this->acarsRepo->getPositions(setting('acars.live_time')); $positions = $this->geoSvc->getFeatureForLiveFlights($pireps); return response(json_encode($positions), 200, [ diff --git a/app/Providers/CronServiceProvider.php b/app/Providers/CronServiceProvider.php index 984a7afb3..281150149 100644 --- a/app/Providers/CronServiceProvider.php +++ b/app/Providers/CronServiceProvider.php @@ -36,6 +36,7 @@ class CronServiceProvider extends ServiceProvider CronHourly::class => [ \App\Cron\Hourly\RemoveExpiredBids::class, + \App\Cron\Hourly\RemoveExpiredLiveFlights::class, ], ]; }