fix: skip snapshots of travels still available as XML from refreshing
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user