fix: match API whitespace handling and skip matchcodes of hidden hotels

This commit is contained in:
fromme committed 2026-09-30 14:57:39 +02:00
1 parent 27832d6548
commit c2dc88b8ab
2 files changed
+13 -4

No files matched your search

@@ -827,7 +827,9 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface
WHERE hotel.code != "" AND hotel.deleted = 0 AND hotel.hidden = 0 WHERE hotel.code != "" AND hotel.deleted = 0 AND hotel.hidden = 0
UNION SELECT matchcode.code code, matchcode.entity uid UNION SELECT matchcode.code code, matchcode.entity uid
FROM tx_epproducts_domain_model_matchcode matchcode FROM tx_epproducts_domain_model_matchcode matchcode
INNER JOIN tx_epproducts_domain_model_hotel matchcode_hotel ON matchcode.entity = matchcode_hotel.uid
WHERE matchcode.deleted = 0 AND matchcode.hidden = 0 WHERE matchcode.deleted = 0 AND matchcode.hidden = 0
AND matchcode_hotel.deleted = 0 AND matchcode_hotel.hidden = 0
ORDER BY code ORDER BY code
) u ) u
LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid LEFT JOIN tx_epproducts_domain_model_hotel h ON u.uid = h.uid
@@ -13,7 +13,9 @@ use Psr\Log\NullLogger;
* *
* Nothing is filtered or rewritten here: every display rule stays in * Nothing is filtered or rewritten here: every display rule stays in
* DateImportService. Prices are parsed from the German format, and a price the * DateImportService. Prices are parsed from the German format, and a price the
* source does not state is null. * source does not state is null. Like the API, service labels and pickup
* cities and streets are trimmed with inner whitespace collapsed; every other
* text is passed on verbatim.
*/ */
final class XmlProductReader implements \IteratorAggregate final class XmlProductReader implements \IteratorAggregate
{ {
@@ -197,7 +199,7 @@ final class XmlProductReader implements \IteratorAggregate
$services[] = [ $services[] = [
'busProId' => (int) $xmlService['idbuspro'], 'busProId' => (int) $xmlService['idbuspro'],
'subType' => (string) $xmlService['unterart'], 'subType' => (string) $xmlService['unterart'],
'label' => (string) $xmlService->text, 'label' => $this->normalizeWhitespace((string) $xmlService->text),
'price' => $this->parsePrice((string) $xmlService->preis), 'price' => $this->parsePrice((string) $xmlService->preis),
'status' => (string) $xmlService->status, 'status' => (string) $xmlService->status,
'direction' => $direction === '' ? null : $direction, 'direction' => $direction === '' ? null : $direction,
@@ -316,14 +318,19 @@ final class XmlProductReader implements \IteratorAggregate
foreach ($xmlData->zustieg as $xmlPickup) { foreach ($xmlData->zustieg as $xmlPickup) {
$pickups[(int) $xmlPickup['idbuspro']] = [ $pickups[(int) $xmlPickup['idbuspro']] = [
'code' => (string) $xmlPickup['code'], 'code' => (string) $xmlPickup['code'],
'city' => (string) $xmlPickup->ort, 'city' => $this->normalizeWhitespace((string) $xmlPickup->ort),
'street' => (string) $xmlPickup->strasse, 'street' => $this->normalizeWhitespace((string) $xmlPickup->strasse),
]; ];
} }
return $pickups; return $pickups;
} }
private function normalizeWhitespace(string $value): string
{
return trim((string) preg_replace('/\s+/u', ' ', $value));
}
private function parseDate(string $value): ?\DateTimeImmutable private function parseDate(string $value): ?\DateTimeImmutable
{ {
$date = \DateTimeImmutable::createFromFormat('!d.m.Y', trim($value), $this->timezone); $date = \DateTimeImmutable::createFromFormat('!d.m.Y', trim($value), $this->timezone);