From c5a24e8ac54135c5c7de24413ddc6ae7646330e0 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 28 Jun 2024 09:27:45 +0200 Subject: [PATCH] DX: Improve Lux address import command - WIP --- .../Service/Import/AddressReferenceLU.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php index 3e45fc565..f5cb03f19 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php +++ b/src/Bundle/ChillMainBundle/Service/Import/AddressReferenceLU.php @@ -42,9 +42,9 @@ class AddressReferenceLU fclose($file); - $uncompressedStream = gzopen($tmpname, 'r'); + //$uncompressedStream = gzopen($tmpname, 'r'); - $csv = Reader::createFromStream($uncompressedStream); + $csv = Reader::createFromStream($file); $csv->setDelimiter(';'); $csv->setHeaderOffset(0); @@ -54,7 +54,7 @@ class AddressReferenceLU $this->addressToReferenceMatcher->checkAddressesMatchingReferences(); - gzclose($uncompressedStream); + //gzclose($uncompressedStream); } private function process_address(Reader $csv): void @@ -67,7 +67,7 @@ class AddressReferenceLU $record['code_postal'], $record['rue'], $record['numero'], - 'bd addresses', + 'bd-addresses.lux', (float) $record['lat_wgs84'], (float) $record['lon_wgs84'], 4326 @@ -82,7 +82,8 @@ class AddressReferenceLU $stmt = Statement::create()->process($csv); $arr_postal_codes = []; foreach ($stmt as $record) { - if (false === \in_array($record['code_postal'], $arr_postal_codes, true)) { + //if (false === \in_array($record['code_postal'], $arr_postal_codes, true)) { + if (false === \array_key_exists($record['code_postal'], $arr_postal_codes, true)) { $this->postalCodeBaseImporter->importCode( 'LU', trim((string) $record['localite']), @@ -93,7 +94,7 @@ class AddressReferenceLU (float) $record['lon_wgs84'], 4326 ); - \array_push($arr_postal_codes, $record['code_postal']); + $arr_postal_codes[$record['code_postal']] = 1; } } }