Check for blank values on import and omit them (#1266)

* Check for blank values on import and omit them

* Add paused status to the pirep changed
This commit is contained in:
Nabeel S 2021-07-22 15:56:03 -04:00 committed by GitHub
parent 78d3c6b577
commit 88a8ffe48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 0 deletions

View File

@ -170,6 +170,11 @@ class ImportExport
} }
foreach ($split_values as $value) { foreach ($split_values as $value) {
$value = trim($value);
if ($value === '') {
continue;
}
// This isn't in the query string format, so it's // This isn't in the query string format, so it's
// just a straight key-value pair set // just a straight key-value pair set
if (strpos($value, '?') === false) { if (strpos($value, '?') === false) {

View File

@ -44,6 +44,7 @@ class PirepStatusChanged extends Notification implements ShouldQueue
PirepStatus::LANDED => 'has landed', PirepStatus::LANDED => 'has landed',
PirepStatus::ARRIVED => 'has arrived', PirepStatus::ARRIVED => 'has arrived',
PirepStatus::CANCELLED => 'is cancelled', PirepStatus::CANCELLED => 'is cancelled',
PirepStatus::PAUSED => 'is paused',
PirepStatus::EMERG_DESCENT => 'in emergency descent', PirepStatus::EMERG_DESCENT => 'in emergency descent',
]; ];

View File

@ -212,6 +212,11 @@ class FlightImporter extends ImportExport
$count = 0; $count = 0;
$subfleets = $this->parseMultiColumnValues($col); $subfleets = $this->parseMultiColumnValues($col);
foreach ($subfleets as $subfleet_type) { foreach ($subfleets as $subfleet_type) {
$subfleet_type = trim($subfleet_type);
if (empty($subfleet_type)) {
continue;
}
$subfleet = Subfleet::firstOrCreate( $subfleet = Subfleet::firstOrCreate(
['type' => $subfleet_type], ['type' => $subfleet_type],
['name' => $subfleet_type] ['name' => $subfleet_type]

View File

@ -149,6 +149,13 @@ class ImporterTest extends TestCase
'Arrival Gate' => 'C61', 'Arrival Gate' => 'C61',
], ],
], ],
// Blank values omitted
[
'input' => 'gate; ',
'expected' => [
'gate',
],
],
]; ];
foreach ($tests as $test) { foreach ($tests as $test) {