feat: refresh existing snapshots from XML after sync
This commit is contained in:
1 parent
909e8a1d8e
commit
3b6ee90a7e
9 files changed
+289
-22
No files matched your search
@@ -9,6 +9,7 @@ use App\Service\TravelSnapshotService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Command\LockableTrait;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -26,6 +27,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
*/
|
||||
class BpnRefreshTravelSnapshotCommand extends Command
|
||||
{
|
||||
use LockableTrait;
|
||||
|
||||
public function __construct(
|
||||
private readonly TravelSnapshotService $snapshotService,
|
||||
private readonly LoggerInterface $logger,
|
||||
@@ -52,19 +55,28 @@ class BpnRefreshTravelSnapshotCommand extends Command
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (false === $this->lock('bpn_xml_sync')) {
|
||||
$this->logger->info('Snapshot refresh skipped: xml-sync is running');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
$limit = (int) $input->getOption('limit');
|
||||
$force = true === $input->getOption('force');
|
||||
$refreshAfterMinutes = (int) $input->getOption('refresh-after');
|
||||
|
||||
$xmlDateIds = [];
|
||||
$xmlFileMap = null;
|
||||
try {
|
||||
$xmlDateIds = array_keys($this->travelLoader->generateFilesMap());
|
||||
$xmlFileMap = $this->travelLoader->generateFilesMap();
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->warning('Failed to load XML files map for snapshot refresh filtering; refreshing all snapshots', [
|
||||
$this->logger->warning('Failed to load XML files map for snapshot refresh filtering; skipping all candidates', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Phase 2 — enrich non-XML-backed snapshots via extended-availability API
|
||||
$xmlDateIds = null !== $xmlFileMap ? array_keys($xmlFileMap) : null;
|
||||
$result = $this->snapshotService->refreshExtendedSnapshots($limit, $force, $refreshAfterMinutes, $xmlDateIds);
|
||||
|
||||
$io->success(sprintf(
|
||||
|
||||
Reference in new issue
Block a user