Add a 'paused' state (#1265)

* Add a 'paused' state

* Check paused status
This commit is contained in:
Nabeel S
2021-07-22 11:59:52 -04:00
committed by GitHub
parent f8ded4e410
commit f42a41286d
9 changed files with 20 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Cron\Hourly;
use App\Contracts\Listener;
use App\Events\CronHourly;
use App\Models\Enums\PirepState;
use App\Models\Enums\PirepStatus;
use App\Models\Pirep;
use App\Services\PirepService;
use Carbon\Carbon;
@@ -38,7 +39,10 @@ class DeletePireps extends Listener
protected function deletePireps(int $expire_time_hours, int $state)
{
$dt = Carbon::now('UTC')->subHours($expire_time_hours);
$pireps = Pirep::where('created_at', '<', $dt)->where(['state' => $state])->get();
$pireps = Pirep::where('created_at', '<', $dt)
->where(['state' => $state])
->where(['status', '<>', PirepStatus::PAUSED])
->get();
/** @var PirepService $pirepSvc */
$pirepSvc = app(PirepService::class);

View File

@@ -32,6 +32,7 @@ class RemoveExpiredLiveFlights extends Listener
$pireps = Pirep::where('updated_at', '<', $date)
->where('state', PirepState::IN_PROGRESS)
->get();
foreach ($pireps as $pirep) {
event(new PirepCancelled($pirep));
Log::info('Cron: Deleting Expired Live PIREP id='.$pirep->id.', state='.PirepState::label($pirep->state));