fix: skip snapshots of travels still available as XML from refreshing

This commit is contained in:
Björn Fromme committed 2026-03-23 19:15:45 +01:00
1 parent 77b16f287a
commit be43d30cc7
3 files changed
+39 -3

No files matched your search

+8 -2
View File
@@ -175,7 +175,7 @@ class TravelSnapshotService
*
* @return array{processed:int,updated:int,failed:int}
*/
public function refreshExtendedSnapshots(int $limit = 500, bool $force = false, int $refreshAfterMinutes = 360): array
public function refreshExtendedSnapshots(int $limit = 500, bool $force = false, int $refreshAfterMinutes = 360, array $xmlAvailableDateIds = []): array
{
$dateToThreshold = new \DateTimeImmutable(sprintf('-%d days', $this->retentionBufferDays));
$refreshBefore = new \DateTimeImmutable(sprintf('-%d minutes', $refreshAfterMinutes));
@@ -184,12 +184,18 @@ class TravelSnapshotService
? $this->snapshotRepository->findAllForMapping($limit)
: $this->snapshotRepository->findRefreshCandidates($dateToThreshold, $refreshBefore, $limit);
$processed = 0;
$updated = 0;
$failed = 0;
/** @var array<int, ExtendedServiceAvailabilityResponse|null> $extendedResponseByDateId */
$extendedResponseByDateId = [];
foreach ($candidates as $snapshot) {
if ([] !== $xmlAvailableDateIds && in_array($snapshot->getDateId(), $xmlAvailableDateIds, true)) {
continue;
}
++$processed;
$dateId = $snapshot->getDateId();
$travel = $this->deserializeTravelFromSnapshot($snapshot);
if (null === $travel) {
@@ -237,7 +243,7 @@ class TravelSnapshotService
}
return [
'processed' => count($candidates),
'processed' => $processed,
'updated' => $updated,
'failed' => $failed,
];