diff --git a/app/Cron/Hourly/RemoveExpiredLiveFlights b/app/Cron/Hourly/RemoveExpiredLiveFlights new file mode 100644 index 00000000..791fa837 --- /dev/null +++ b/app/Cron/Hourly/RemoveExpiredLiveFlights @@ -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 08bd0c3f..41f904bf 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 56280f97..155bf740 100644 --- a/app/Http/Controllers/Api/AcarsController.php +++ b/app/Http/Controllers/Api/AcarsController.php @@ -69,7 +69,7 @@ class AcarsController extends Controller */ 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 984a7afb..28115014 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, ], ]; }