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

@@ -22,10 +22,10 @@ class AddressReferenceBEFromBestAddress
public function __construct(private readonly HttpClientInterface $client, private readonly AddressReferenceBaseImporter $baseImporter, private readonly AddressToReferenceMatcher $addressToReferenceMatcher) {}
public function import(string $lang, array $lists): void
public function import(string $lang, array $lists, ?string $sendAddressReportToEmail = null): void
{
foreach ($lists as $list) {
$this->importList($lang, $list);
$this->importList($lang, $list, $sendAddressReportToEmail);
}
}
@@ -43,7 +43,7 @@ class AddressReferenceBEFromBestAddress
return array_values($asset)[0]['browser_download_url'];
}
private function importList(string $lang, string $list): void
private function importList(string $lang, string $list, ?string $sendAddressReportToEmail = null): void
{
$downloadUrl = $this->getDownloadUrl($lang, $list);
@@ -85,7 +85,7 @@ class AddressReferenceBEFromBestAddress
);
}
$this->baseImporter->finalize();
$this->baseImporter->finalize(sendAddressReportToEmail: $sendAddressReportToEmail);
$this->addressToReferenceMatcher->checkAddressesMatchingReferences();