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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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));

View File

@ -4,9 +4,6 @@ namespace App\Models\Enums;
use App\Contracts\Enum;
/**
* Class PirepState
*/
class PirepState extends Enum
{
public const IN_PROGRESS = 0; // flight is ongoing
@ -16,6 +13,7 @@ class PirepState extends Enum
public const DELETED = 4;
public const DRAFT = 5;
public const REJECTED = 6;
public const PAUSED = 7;
protected static $labels = [
self::IN_PROGRESS => 'pireps.state.in_progress',
@ -25,5 +23,6 @@ class PirepState extends Enum
self::DELETED => 'pireps.state.deleted',
self::DRAFT => 'pireps.state.draft',
self::REJECTED => 'pireps.state.rejected',
self::PAUSED => 'pireps.state.paused',
];
}

View File

@ -34,6 +34,7 @@ class PirepStatus extends Enum
public const ARRIVED = 'ONB'; // On block
public const CANCELLED = 'DX';
public const EMERG_DESCENT = 'EMG';
public const PAUSED = 'PSD';
protected static $labels = [
self::INITIATED => 'pireps.status.initialized',
@ -59,5 +60,6 @@ class PirepStatus extends Enum
self::ARRIVED => 'pireps.status.arrived',
self::CANCELLED => 'pireps.status.cancelled',
self::EMERG_DESCENT => 'pireps.status.emerg_decent',
self::PAUSED => 'pireps.status.paused',
];
}

View File

@ -43,6 +43,7 @@ return [
'cancelled' => 'Abgebrochen',
'deleted' => 'Gelöscht',
'draft' => 'Entwurf',
'paused' => 'Angehalten',
],
'status' => [
'initialized' => 'Erstellt',
@ -66,5 +67,6 @@ return [
'arrived' => 'Angekommen',
'cancelled' => 'Abgebrochen',
'emerg_decent' => 'Notfall dezent',
'paused' => 'Angehalten',
],
];

View File

@ -43,6 +43,7 @@ return [
'cancelled' => 'Cancelled',
'deleted' => 'Deleted',
'draft' => 'Draft',
'paused' => 'Paused',
],
'status' => [
'initialized' => 'Initiated',
@ -66,5 +67,6 @@ return [
'arrived' => 'Arrived',
'cancelled' => 'Cancelled',
'emerg_decent' => 'Emergency decent',
'paused' => 'Paused',
],
];

View File

@ -43,6 +43,7 @@ return [
'cancelled' => 'Cancelado',
'deleted' => 'Eliminado',
'draft' => 'Borrador',
'paused' => 'Pausado',
],
'status' => [
'initialized' => 'Iniciado',
@ -66,5 +67,6 @@ return [
'arrived' => 'Llegó',
'cancelled' => 'Cancelado',
'emerg_decent' => 'Descenso de emergencía',
'paused' => 'Pausado',
],
];

View File

@ -44,6 +44,7 @@ return [
'cancelled' => 'Cancellato',
'deleted' => 'Eliminato',
'draft' => 'Bozza',
'paused' => 'In pausa',
],
'status' => [
'initialized' => 'Iniziato',
@ -67,5 +68,6 @@ return [
'arrived' => 'Arrivato',
'cancelled' => 'Cancellato',
'emerg_decent' => 'Discesa di Emergenza',
'paused' => 'In pausa',
],
];

View File

@ -43,6 +43,7 @@ return [
'cancelled' => 'Cancelado',
'deleted' => 'Deletado',
'draft' => 'Esboçado',
'paused' => 'Em pausa',
],
'status' => [
'initialized' => 'Iniciada',
@ -66,5 +67,6 @@ return [
'arrived' => 'Chegou',
'cancelled' => 'Cancelado',
'emerg_decent' => 'Descida de emergência',
'paused' => 'Em pausa',
],
];