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

This commit is contained in:
Björn Fromme
2026-03-23 19:15:45 +01:00
parent 77b16f287a
commit be43d30cc7
3 changed files with 39 additions and 3 deletions
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Command;
use App\BusProNet\XmlLoader\TravelLoader;
use App\Service\TravelSnapshotService;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
@@ -28,6 +29,7 @@ class BpnRefreshTravelSnapshotCommand extends Command
public function __construct(
private readonly TravelSnapshotService $snapshotService,
private readonly LoggerInterface $logger,
private readonly TravelLoader $travelLoader,
) {
parent::__construct();
}
@@ -54,7 +56,16 @@ class BpnRefreshTravelSnapshotCommand extends Command
$force = true === $input->getOption('force');
$refreshAfterMinutes = (int) $input->getOption('refresh-after');
$result = $this->snapshotService->refreshExtendedSnapshots($limit, $force, $refreshAfterMinutes);
$xmlDateIds = [];
try {
$xmlDateIds = array_keys($this->travelLoader->generateFilesMap());
} catch (\Throwable $e) {
$this->logger->warning('Failed to load XML files map for snapshot refresh filtering; refreshing all snapshots', [
'error' => $e->getMessage(),
]);
}
$result = $this->snapshotService->refreshExtendedSnapshots($limit, $force, $refreshAfterMinutes, $xmlDateIds);
$io->success(sprintf(
'Snapshot refresh complete: %d processed, %d updated, %d failed',