diff --git a/src/Command/ElectedRepresentativeOhmeUpdateCommand.php b/src/Command/ElectedRepresentativeOhmeUpdateCommand.php deleted file mode 100644 index 8443febb67..0000000000 --- a/src/Command/ElectedRepresentativeOhmeUpdateCommand.php +++ /dev/null @@ -1,105 +0,0 @@ -io = new SymfonyStyle($input, $output); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $count = 0; - $offset = 0; - $limit = 100; - - do { - $contacts = $this->ohme->getContacts($limit, $offset); - - if (0 === $count) { - if (empty($contacts['count'])) { - $this->io->error('No contact found from Ohme API'); - } - - $count = $contacts['count']; - - $this->io->progressStart($count); - } - - foreach ($contacts['data'] as $contact) { - $this->io->progressAdvance(); - - if (empty($contact['uuid_adherent'])) { - continue; - } - - if (!$adherent = $this->adherentRepository->findOneByUuid($contact['uuid_adherent'])) { - $this->io->warning(\sprintf('Adherent with uuid "%s" has not been found.', $contact['uuid_adherent'])); - - continue; - } - - $payments = $this->ohme->getPayments(['contact_id' => $contact['id']]); - - foreach ($payments['data'] as $paymentData) { - if (!$payment = $adherent->getPaymentByOhmeId($paymentData['id'])) { - $adherent->addPayment($payment = Payment::fromArray($adherent, $paymentData)); - } - - $payment->status = $paymentData['payment_status']; - } - - $this->entityManager->flush(); - $this->bus->dispatch(new AsyncRefreshAdherentTagCommand($adherent->getUuid())); - - $this->pause(); - } - - $this->entityManager->clear(); - - $offset += $limit; - - $this->pause(); - } while (0 !== $count && 0 !== $offset && $offset < $count); - - $this->io->progressFinish(); - - return self::SUCCESS; - } - - private function pause(): void - { - // Avoid OHME rate limit (100 requests / minute) - usleep(700000); - } -}