Add email reporting for unimported addresses in import commands

Enhanced address import commands to optionally send a recap of unimported addresses via email. Updated import logic to handle cases where postal codes are missing, log issues, and generate compressed CSV reports with failed entries.
This commit is contained in:
2025-01-09 12:21:10 +01:00
parent 96bb98f854
commit ab311eaecb
9 changed files with 113 additions and 29 deletions

View File

@@ -21,7 +21,7 @@ class AddressReferenceLU
public function __construct(private readonly HttpClientInterface $client, private readonly AddressReferenceBaseImporter $addressBaseImporter, private readonly PostalCodeBaseImporter $postalCodeBaseImporter, private readonly AddressToReferenceMatcher $addressToReferenceMatcher) {}
public function import(): void
public function import(?string $sendAddressReportToEmail = null): void
{
$downloadUrl = self::RELEASE;
@@ -45,14 +45,14 @@ class AddressReferenceLU
$this->process_postal_code($csv);
$this->process_address($csv);
$this->process_address($csv, $sendAddressReportToEmail);
$this->addressToReferenceMatcher->checkAddressesMatchingReferences();
fclose($file);
}
private function process_address(Reader $csv): void
private function process_address(Reader $csv, ?string $sendAddressReportToEmail = null): void
{
$stmt = Statement::create()->process($csv);
foreach ($stmt as $record) {
@@ -69,7 +69,7 @@ class AddressReferenceLU
);
}
$this->addressBaseImporter->finalize();
$this->addressBaseImporter->finalize(sendAddressReportToEmail: $sendAddressReportToEmail);
}
private function process_postal_code(Reader $csv): void