-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from nkevins/expired_flight_cleaning
Hide expired live flight from live map and remove from DB
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Cron\Hourly; | ||
|
||
use App\Events\CronHourly; | ||
use App\Interfaces\Listener; | ||
use App\Models\Pirep; | ||
use Carbon\Carbon; | ||
|
||
/** | ||
* Remove expired live flights | ||
*/ | ||
class RemoveExpiredLiveFlights extends Listener | ||
{ | ||
/** | ||
* Remove expired live flights | ||
* | ||
* @param CronHourly $event | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function handle(CronHourly $event): void | ||
{ | ||
if (setting('acars.live_time') === 0) { | ||
return; | ||
} | ||
|
||
$date = Carbon::now()->subHours(setting('acars.live_time')); | ||
Pirep::whereDate('created_at', '<', $date) | ||
->where('state', PirepState::IN_PROGRESS) | ||
->delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters