diff --git a/docs/technical-documentation.md b/docs/technical-documentation.md index 5372caa..f34b609 100644 --- a/docs/technical-documentation.md +++ b/docs/technical-documentation.md @@ -1129,14 +1129,6 @@ php bin/console app:draft:inspect [--days|-d ] [--booking-id|-b ] [--dele Inspects and optionally deletes drafts. -#### app:draft:backfill-booking-number - -```bash -php bin/console app:draft:backfill-booking-number [--dry-run] -``` - -Populates missing booking numbers from API. - #### app:cleanup:log-entries ```bash diff --git a/src/Command/DraftBackfillBookingNumberCommand.php b/src/Command/DraftBackfillBookingNumberCommand.php deleted file mode 100644 index 4ec14e6..0000000 --- a/src/Command/DraftBackfillBookingNumberCommand.php +++ /dev/null @@ -1,119 +0,0 @@ -addOption('dry-run', null, InputOption::VALUE_NONE, 'Show what would be updated without actually updating'); - } - - /** - * @see Command::execute() - */ - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = new SymfonyStyle($input, $output); - $dryRun = $input->getOption('dry-run'); - - $drafts = $this->draftRepository->findBy(['bookingNumber' => null]); - - if (0 === \count($drafts)) { - $io->success('No drafts without booking number found.'); - - return Command::SUCCESS; - } - - $io->title(sprintf('Processing %d draft(s)', \count($drafts))); - - $updated = 0; - $failed = 0; - $skipped = 0; - - foreach ($drafts as $draft) { - $bookingId = $draft->getBookingId(); - $user = $draft->getUser(); - - $bookingData = $this->dataLoader->fetchBookingData($bookingId, $user); - - if (!$bookingData instanceof Booking) { - $io->warning(sprintf('Could not fetch booking %d for user %s', $bookingId, $user->getEmail())); - ++$failed; - - continue; - } - - // bookingNumber maps to BPN XML vorgang - $bookingNumber = $bookingData->bookingNumber; - - if (null === $bookingNumber) { - $io->warning(sprintf('No booking number (vorgang) found for booking %d', $bookingId)); - ++$skipped; - - continue; - } - - if ($dryRun) { - $io->text(sprintf( - '[DRY RUN] Would set booking number %d for draft %d (bookingId %d)', - $bookingNumber, - $draft->getId(), - $bookingId - )); - } else { - $draft->setBookingNumber($bookingNumber); - } - - ++$updated; - } - - if (false === $dryRun) { - $this->entityManager->flush(); - } - - $io->newLine(); - $io->table( - ['Status', 'Count'], - [ - ['Updated', $updated], - ['Failed (API error)', $failed], - ['Skipped (no booking number)', $skipped], - ] - ); - - if ($dryRun) { - $io->note('Dry run - no changes were made.'); - } else { - $io->success(sprintf('Updated %d draft(s).', $updated)); - } - - return Command::SUCCESS; - } -}