diff --git a/app/Database/seeds/settings.yml b/app/Database/seeds/settings.yml index 4cd13c05..b08241d6 100644 --- a/app/Database/seeds/settings.yml +++ b/app/Database/seeds/settings.yml @@ -130,6 +130,20 @@ options: '' type: int description: 'Initial zoom level on the map' +- key: airports.default_ground_handling_cost + name: 'Default Ground Handling Cost' + group: airports + value: 250 + options: + type: int + description: If an airport's Ground Handling Cost Cost isn't added, set this value by default +- key: airports.default_jet_a_fuel_cost + name: 'Default Jet A Fuel Cost' + group: airports + value: 0.7 + options: + type: text + description: If an airport's Jet A Fuel Cost isn't added, set this value by default - key: bids.disable_flight_on_bid name: 'Disable flight on bid' group: bids diff --git a/app/Http/Controllers/System/UpdateController.php b/app/Http/Controllers/System/UpdateController.php index d042da6d..93bd48eb 100644 --- a/app/Http/Controllers/System/UpdateController.php +++ b/app/Http/Controllers/System/UpdateController.php @@ -105,7 +105,7 @@ class UpdateController extends Controller */ public function complete() { - return redirect('/login'); + return redirect('/admin'); } /** diff --git a/app/Services/ImportExport/AirportImporter.php b/app/Services/ImportExport/AirportImporter.php index 7fbefe6a..29f7b5bc 100644 --- a/app/Services/ImportExport/AirportImporter.php +++ b/app/Services/ImportExport/AirportImporter.php @@ -45,8 +45,20 @@ class AirportImporter extends ImportExport $row['id'] = $row['icao']; $row['hub'] = get_truth_state($row['hub']); + if ($row['ground_handling_cost'] === null && $row['ground_handling_cost'] !== 0.0) { + $row['ground_handling_cost'] = (float) setting('airports.default_ground_handling_cost'); + } else { + $row['ground_handling_cost'] = (float) $row['ground_handling_cost']; + } + + if ($row['fuel_jeta_cost'] === null && $row['fuel_jeta_cost'] !== 0.0) { + $row['fuel_jeta_cost'] = (float) setting('airports.default_jet_a_fuel_cost'); + } else { + $row['fuel_jeta_cost'] = (float) $row['fuel_jeta_cost']; + } + try { - $airport = Airport::updateOrCreate([ + Airport::updateOrCreate([ 'id' => $row['icao'], ], $row); } catch (\Exception $e) { diff --git a/app/Services/Importers/AirportImporter.php b/app/Services/Importers/AirportImporter.php index 0c2d11bc..68f1652d 100644 --- a/app/Services/Importers/AirportImporter.php +++ b/app/Services/Importers/AirportImporter.php @@ -21,19 +21,34 @@ class AirportImporter extends BaseImporter 'lat', 'lng', 'hub', + 'ground_handling_cost', + 'fuel_jeta_cost', ]; $count = 0; $rows = $this->db->readRows($this->table, $this->idField, $start, $fields); foreach ($rows as $row) { + $ground_handling_cost = (float) $row->ground_handling_cost; + $fuel_jetA_cost = (float) $row->fuel_jeta_cost; + + if ($ground_handling_cost === null && $ground_handling_cost !== 0) { + $ground_handling_cost = (float) setting('general.default_ground_handling_cost'); + } + + if ($fuel_jetA_cost === null && $fuel_jetA_cost !== 0) { + $fuel_jetA_cost = (float) setting('general.default_jetA_fuel_cost'); + } + $attrs = [ - 'id' => trim($row->icao), - 'icao' => trim($row->icao), - 'name' => $row->name, - 'country' => $row->country, - 'lat' => $row->lat, - 'lon' => $row->lng, - 'hub' => $row->hub, + 'id' => trim($row->icao), + 'icao' => trim($row->icao), + 'name' => $row->name, + 'country' => $row->country, + 'lat' => $row->lat, + 'lon' => $row->lng, + 'hub' => $row->hub, + 'ground_handling_cost' => $ground_handling_cost, + 'fuel_jeta_cost' => $fuel_jetA_cost, ]; $w = ['id' => $attrs['id']]; diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index 7c416dcd..ffd3524f 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -633,6 +633,8 @@ class ImporterTest extends TestCase $this->assertEquals(true, $airport->hub); $this->assertEquals('30.1945', $airport->lat); $this->assertEquals('-97.6699', $airport->lon); + $this->assertEquals(0.0, $airport->ground_handling_cost); + $this->assertEquals(setting('airports.default_jet_a_fuel_cost'), $airport->fuel_jeta_cost); // See if it imported $airport = Airport::where([ @@ -641,6 +643,8 @@ class ImporterTest extends TestCase $this->assertNotNull($airport); $this->assertEquals(true, $airport->hub); + $this->assertEquals(0.9, $airport->fuel_jeta_cost); + $this->assertEquals(setting('airports.default_ground_handling_cost'), $airport->ground_handling_cost); } /** diff --git a/tests/data/airports.csv b/tests/data/airports.csv index 72a31c72..4990410f 100644 --- a/tests/data/airports.csv +++ b/tests/data/airports.csv @@ -1,4 +1,4 @@ icao,iata,name,location,country,timezone,hub,lat,lon,ground_handling_cost,fuel_100ll_cost,fuel_jeta_cost,fuel_mogas_cost -KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,,,, -KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,"1",30.1945,-97.6699,,,, -KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,,,, +KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699,0,,, +KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,1,30.1945,-97.6699,,,0.9, +KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd,150,,0.8,