fix: make BusProNet response failures diagnosable and non-fatal
This commit is contained in:
1 parent
29cedd5916
commit
a05143bfbe
8 files changed
+207
-19
No files matched your search
@@ -56,11 +56,30 @@ class BpnImportCommand extends Command
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
// Resolve the BusProNet base data once, before touching a single row. A destination
|
||||
// cannot be written without its hotel, so an unavailable hotel list would otherwise
|
||||
// skip every record and still report success. Holding both lists locally also keeps
|
||||
// the loop off the providers: on a failed fetch nothing is cached, and a per-lookup
|
||||
// ->get() would re-open the socket for every pickup of all 174 files.
|
||||
$hotels = $this->hotelDataProvider->getAll();
|
||||
$pickups = $this->pickupDataProvider->getAll();
|
||||
|
||||
if ([] === $hotels) {
|
||||
$io->error('Hotel-Stammdaten konnten nicht von BusProNet geladen werden – Import abgebrochen.');
|
||||
$this->logger->error('BPN import aborted: hotel base data unavailable');
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$io->info('Found '.$totalCount.' XML files');
|
||||
$addedCount = 0;
|
||||
$updatedCount = 0;
|
||||
$warnings = [];
|
||||
|
||||
if ([] === $pickups) {
|
||||
$warnings[] = 'Zustiegs-Stammdaten konnten nicht von BusProNet geladen werden';
|
||||
}
|
||||
|
||||
$progressBar = $io->createProgressBar($totalCount);
|
||||
$progressBar->setFormat(" %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%\n %message%");
|
||||
$progressBar->setMessage('Starting');
|
||||
@@ -92,7 +111,7 @@ class BpnImportCommand extends Command
|
||||
foreach ($destinationXml->xpath('zustiege/zustieg') as $pickupXml) {
|
||||
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
||||
if ($pickupBusProId) {
|
||||
if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) {
|
||||
if (null === $pickup = $pickups[$pickupBusProId] ?? null) {
|
||||
$warnings[] = 'Pickup with busProId '.$pickupBusProId.' not found';
|
||||
continue;
|
||||
}
|
||||
@@ -109,7 +128,7 @@ class BpnImportCommand extends Command
|
||||
// Iterate over all hotel entries
|
||||
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
||||
$hotelBusProId = (int) $hotelXml->attributes()['idbuspro'];
|
||||
if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) {
|
||||
if (null === $hotel = $hotels[$hotelBusProId] ?? null) {
|
||||
$warnings[] = 'Hotel with busProId '.$hotelBusProId.' not found';
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user