From 06be75cf6f5119167d17cd7d757d642b21e58dc9 Mon Sep 17 00:00:00 2001 From: Dorota Hawro Date: Fri, 3 Jan 2025 11:08:45 +0000 Subject: [PATCH] DON-998 - make batch limit a constant --- src/Application/Commands/TakeRegularGivingDonations.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Application/Commands/TakeRegularGivingDonations.php b/src/Application/Commands/TakeRegularGivingDonations.php index 4d691e57..3c555964 100644 --- a/src/Application/Commands/TakeRegularGivingDonations.php +++ b/src/Application/Commands/TakeRegularGivingDonations.php @@ -27,8 +27,9 @@ )] class TakeRegularGivingDonations extends LockingCommand { + private const int MAXBATCHSIZE = 20; private ?RegularGivingService $mandateService = null; - private int $limit = 20; + /** @psalm-suppress PossiblyUnusedMethod - called by PHP-DI */ public function __construct( @@ -91,7 +92,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in private function createNewDonationsAccordingToRegularGivingMandates(\DateTimeImmutable $now, SymfonyStyle $io): void { - $mandates = $this->mandateRepository->findMandatesWithDonationsToCreateOn($now, $this->limit); + $mandates = $this->mandateRepository->findMandatesWithDonationsToCreateOn($now, self::MAXBATCHSIZE); $io->block(count($mandates) . " mandates may have donations to create at this time"); @@ -108,7 +109,7 @@ private function setPaymentIntentWhenReachedPaymentDate( \DateTimeImmutable $now, SymfonyStyle $io ): void { - $donations = $this->donationRepository->findDonationsToSetPaymentIntent($now, $this->limit); + $donations = $this->donationRepository->findDonationsToSetPaymentIntent($now, self::MAXBATCHSIZE); $io->block(count($donations) . " donations are due to have Payment Intent set at this time"); foreach ($donations as $donation) { @@ -127,7 +128,7 @@ private function confirmPreCreatedDonationsThatHaveReachedPaymentDate( - Ensure we don't send emails that are meant for confirmation of on-session donations - Probably other things. */ - $donations = $this->donationRepository->findPreAuthorizedDonationsReadyToConfirm($now, limit:20); + $donations = $this->donationRepository->findPreAuthorizedDonationsReadyToConfirm($now, self::MAXBATCHSIZE); $io->block(count($donations) . " donations are due to be confirmed at this time");