Fix flight hours field #683 (#684)

This commit is contained in:
Nabeel S 2020-05-05 14:36:14 -04:00 committed by GitHub
parent 9135337186
commit 5b771be653
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 2 deletions

View File

@ -141,24 +141,28 @@ aircraft:
airport_id: KJFK airport_id: KJFK
name: Boeing 747-438 name: Boeing 747-438
registration: 001Z registration: 001Z
flight_time: 360
status: A status: A
- id: 2 - id: 2
subfleet_id: 2 subfleet_id: 2
airport_id: LGRP airport_id: LGRP
name: Boeing 777-200 name: Boeing 777-200
registration: C202 registration: C202
flight_time: 260
status: A status: A
- id: 3 - id: 3
subfleet_id: 1 subfleet_id: 1
airport_id: KAUS airport_id: KAUS
name: Boeing 747-412 name: Boeing 747-412
registration: S2333 registration: S2333
flight_time: 0
status: A status: A
- id: 4 - id: 4
subfleet_id: 1 subfleet_id: 1
airport_id: KAUS airport_id: KAUS
name: Boeing 747-436 RETIRED name: Boeing 747-436 RETIRED
registration: registration:
flight_time: 45
status: R status: R
expenses: expenses:

View File

@ -38,6 +38,7 @@ class Aircraft extends Model
'name', 'name',
'registration', 'registration',
'hex_code', 'hex_code',
'flight_time',
'zfw', 'zfw',
'status', 'status',
'state', 'state',
@ -49,6 +50,7 @@ class Aircraft extends Model
protected $casts = [ protected $casts = [
'subfleet_id' => 'integer', 'subfleet_id' => 'integer',
'zfw' => 'float', 'zfw' => 'float',
'flight_time' => 'float',
'state' => 'integer', 'state' => 'integer',
]; ];

View File

@ -24,7 +24,7 @@
</td> </td>
<td style="text-align: center;">{{ $ac->airport_id }}</td> <td style="text-align: center;">{{ $ac->airport_id }}</td>
<td style="text-align: center;"> <td style="text-align: center;">
@minutestotime($ac->flight_hours) @minutestotime($ac->flight_time)
</td> </td>
<td style="text-align: center;"> <td style="text-align: center;">
@if($ac->status == \App\Models\Enums\AircraftStatus::ACTIVE) @if($ac->status == \App\Models\Enums\AircraftStatus::ACTIVE)

View File

@ -225,6 +225,9 @@ class PIREPTest extends TestCase
'flight_time' => 360, 'flight_time' => 360,
]); ]);
$aircraft = Aircraft::find(1);
$flight_time_initial = $aircraft->flight_time;
foreach ($pireps as $pirep) { foreach ($pireps as $pirep) {
$this->pirepSvc->create($pirep); $this->pirepSvc->create($pirep);
$this->pirepSvc->accept($pirep); $this->pirepSvc->accept($pirep);
@ -236,9 +239,12 @@ class PIREPTest extends TestCase
// Make sure rank went up // Make sure rank went up
$this->assertGreaterThan($user->rank_id, $pilot->rank_id); $this->assertGreaterThan($user->rank_id, $pilot->rank_id);
$this->assertEquals($last_pirep->arr_airport_id, $pilot->curr_airport_id); $this->assertEquals($last_pirep->arr_airport_id, $pilot->curr_airport_id);
$this->assertEquals(2, $pilot->flights); $this->assertEquals(2, $pilot->flights);
$aircraft = Aircraft::find(1);
$after_time = $flight_time_initial + 720;
$this->assertEquals($after_time, $aircraft->flight_time);
// //
// Submit another PIREP, adding another 6 hours // Submit another PIREP, adding another 6 hours
// it should automatically be accepted // it should automatically be accepted