From 88a8ffe48acda4ef9e7d7bbb48a7a8fe9131b8fd Mon Sep 17 00:00:00 2001 From: Nabeel S Date: Thu, 22 Jul 2021 15:56:03 -0400 Subject: [PATCH] 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 --- app/Contracts/ImportExport.php | 5 +++++ app/Notifications/Messages/PirepStatusChanged.php | 1 + app/Services/ImportExport/FlightImporter.php | 5 +++++ tests/ImporterTest.php | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/app/Contracts/ImportExport.php b/app/Contracts/ImportExport.php index b0d215ef..9acef9a0 100644 --- a/app/Contracts/ImportExport.php +++ b/app/Contracts/ImportExport.php @@ -170,6 +170,11 @@ class ImportExport } foreach ($split_values as $value) { + $value = trim($value); + if ($value === '') { + continue; + } + // This isn't in the query string format, so it's // just a straight key-value pair set if (strpos($value, '?') === false) { diff --git a/app/Notifications/Messages/PirepStatusChanged.php b/app/Notifications/Messages/PirepStatusChanged.php index 39c042e1..c7de8bd9 100644 --- a/app/Notifications/Messages/PirepStatusChanged.php +++ b/app/Notifications/Messages/PirepStatusChanged.php @@ -44,6 +44,7 @@ class PirepStatusChanged extends Notification implements ShouldQueue PirepStatus::LANDED => 'has landed', PirepStatus::ARRIVED => 'has arrived', PirepStatus::CANCELLED => 'is cancelled', + PirepStatus::PAUSED => 'is paused', PirepStatus::EMERG_DESCENT => 'in emergency descent', ]; diff --git a/app/Services/ImportExport/FlightImporter.php b/app/Services/ImportExport/FlightImporter.php index c8ced548..422a981b 100644 --- a/app/Services/ImportExport/FlightImporter.php +++ b/app/Services/ImportExport/FlightImporter.php @@ -212,6 +212,11 @@ class FlightImporter extends ImportExport $count = 0; $subfleets = $this->parseMultiColumnValues($col); foreach ($subfleets as $subfleet_type) { + $subfleet_type = trim($subfleet_type); + if (empty($subfleet_type)) { + continue; + } + $subfleet = Subfleet::firstOrCreate( ['type' => $subfleet_type], ['name' => $subfleet_type] diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index 7f63129d..e0d77276 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -149,6 +149,13 @@ class ImporterTest extends TestCase 'Arrival Gate' => 'C61', ], ], + // Blank values omitted + [ + 'input' => 'gate; ', + 'expected' => [ + 'gate', + ], + ], ]; foreach ($tests as $test) {