add PIREP pre-file and ACARS updates; removing caching from ACARS/Pirep/User repositories; adjust PirepState enum values; add additional columns
This commit is contained in:
20
app/Database/factories/AcarsFactory.php
Normal file
20
app/Database/factories/AcarsFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\Acars::class, function (Faker $faker) {
|
||||
return [
|
||||
'id' => substr($faker->unique()->sha1, 0, 12),
|
||||
'pirep_id' => '', # TODO: Fill this out
|
||||
'lat' => $faker->latitude,
|
||||
'lon' => $faker->longitude,
|
||||
'heading' => $faker->numberBetween(0, 359),
|
||||
'altitude' => $faker->numberBetween(20, 400),
|
||||
'vs' => $faker->numberBetween(-5000, 5000),
|
||||
'gs' => $faker->numberBetween(300, 500),
|
||||
'transponder' => $faker->numberBetween(200, 9999),
|
||||
'autopilot' => $faker->text(10),
|
||||
'fuel_flow' => $faker->randomFloat(2, 100, 1000),
|
||||
'sim_time' => $faker->dateTime('now', 'UTC'),
|
||||
];
|
||||
});
|
||||
@@ -1,23 +1,19 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Enums\PirepSource;
|
||||
use App\Models\Enums\PirepState;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
# Match the list available in tests/data/*.yml
|
||||
|
||||
$airlinesAvailable = [1];
|
||||
|
||||
/**
|
||||
* Create a new PIREP
|
||||
*/
|
||||
$factory->define(App\Models\Pirep::class, function (Faker $faker) use ($airlinesAvailable) {
|
||||
$factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
|
||||
static $raw_data;
|
||||
|
||||
return [
|
||||
'id' => substr($faker->unique()->sha1, 0, 12),
|
||||
'airline_id' => 1, #$faker->randomElement($airlinesAvailable),
|
||||
'airline_id' => function () { # OVERRIDE THIS IF NEEDED
|
||||
return factory(App\Models\Airline::class)->create()->id;
|
||||
},
|
||||
'user_id' => function () { # OVERRIDE THIS IF NEEDED
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
@@ -39,11 +35,15 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) use ($airlines
|
||||
'arr_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'altitude' => $faker->numberBetween(20, 400),
|
||||
'flight_time' => $faker->randomFloat(2),
|
||||
'planned_flight_time' => $faker->randomFloat(2),
|
||||
'gross_weight' => $faker->randomFloat(2),
|
||||
'route' => $faker->text(200),
|
||||
'notes' => $faker->text(200),
|
||||
'source' => $faker->randomElement([PirepSource::MANUAL, PirepSource::ACARS]),
|
||||
'state' => PirepState::PENDING, //$faker->randomElement([-1, 0, 1]), # REJECTED/PENDING/ACCEPTED
|
||||
'state' => PirepState::PENDING,
|
||||
'status' => PirepStatus::SCHEDULED,
|
||||
'raw_data' => $raw_data ?: $raw_data = json_encode(['key' => 'value']),
|
||||
'created_at' => $faker->dateTimeBetween('-1 week', 'now'),
|
||||
'updated_at' => function(array $pirep) {
|
||||
|
||||
@@ -22,10 +22,10 @@ class CreateFlightTables extends Migration
|
||||
$table->string('dpt_airport_id', 5);
|
||||
$table->string('arr_airport_id', 5);
|
||||
$table->string('alt_airport_id', 5)->nullable();
|
||||
$table->text('route')->nullable();
|
||||
$table->string('dpt_time', 10)->nullable();
|
||||
$table->string('arr_time', 10)->nullable();
|
||||
$table->unsignedDecimal('flight_time', 19)->nullable();
|
||||
$table->text('route')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->boolean('has_bid')->default(false);
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Enums\PirepState;
|
||||
use App\Models\Enums\PirepStatus;
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
@@ -24,14 +27,16 @@ class CreatePirepTables extends Migration
|
||||
$table->string('route_leg', 5)->nullable();
|
||||
$table->string('dpt_airport_id', 5);
|
||||
$table->string('arr_airport_id', 5);
|
||||
$table->unsignedDecimal('flight_time', 19);
|
||||
$table->unsignedInteger('altitude')->nullable();
|
||||
$table->unsignedDecimal('flight_time', 19)->nullable();
|
||||
$table->unsignedDecimal('planned_flight_time', 19)->nullable();
|
||||
$table->unsignedDecimal('gross_weight', 19)->nullable();
|
||||
$table->unsignedDecimal('fuel_used', 19)->nullable();
|
||||
$table->string('route', 250)->nullable();
|
||||
$table->string('notes', 250)->nullable();
|
||||
$table->text('route')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->unsignedTinyInteger('source')->default(0);
|
||||
$table->tinyInteger('state')->default(0); # -1 rejected, 0 pending, 1 accepted
|
||||
#$table->tinyInteger('status')->default(0); # -1 rejected, 0 pending, 1 accepted
|
||||
$table->tinyInteger('state')->default(PirepState::PENDING);
|
||||
$table->tinyInteger('status')->default(PirepStatus::SCHEDULED);
|
||||
$table->longText('raw_data')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -14,22 +14,24 @@ class CreateAcarsTables extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('acars', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('id', 12);
|
||||
$table->string('pirep_id', 12);
|
||||
$table->string('name', 10)->nullable();
|
||||
$table->float('lat', 7, 4)->default(0.0);
|
||||
$table->float('lon', 7, 4)->default(0.0);
|
||||
|
||||
# TODO: More columns here for what might be required
|
||||
|
||||
# polymorphic relation columns.
|
||||
# parent_type can be flight, pirep or acars
|
||||
# once
|
||||
#$table->unsignedBigInteger('parent_id');
|
||||
#$table->string('parent_type');
|
||||
$table->unsignedInteger('heading')->nullable();
|
||||
$table->unsignedInteger('altitude')->nullable();
|
||||
$table->integer('vs')->nullable();
|
||||
$table->unsignedInteger('gs')->nullable();
|
||||
$table->unsignedInteger('transponder')->nullable();
|
||||
$table->string('autopilot')->nullable();
|
||||
$table->decimal('fuel_flow')->nullable();
|
||||
$table->dateTimeTz('sim_time')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary('id');
|
||||
$table->index('pirep_id');
|
||||
$table->index('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ pireps:
|
||||
dpt_airport_id: KAUS
|
||||
arr_airport_id: KJFK
|
||||
flight_time: 180 # 6 hours
|
||||
state: 0
|
||||
state: 1
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
@@ -359,7 +359,7 @@ pireps:
|
||||
dpt_airport_id: KJFK
|
||||
arr_airport_id: KAUS
|
||||
flight_time: 180 # 6 hours
|
||||
state: 0
|
||||
state: 1
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
@@ -372,7 +372,7 @@ pireps:
|
||||
dpt_airport_id: KJFK
|
||||
arr_airport_id: KAUS
|
||||
flight_time: 180 # 6 hours
|
||||
state: 0
|
||||
state: 1
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
|
||||
Reference in New Issue
Block a user