Skip to content

Commit db6d775

Browse files
authored
Activate "inactive-donors" command (#471)
1 parent 3f77549 commit db6d775

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

config/crontab.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
10 7 * * * php /var/www/solidarityMSP/bin/console app:transaction:notify-donors >> /var/www/solidarityMSP/var/log/crontab-transaction-notify-donors-`date +\%d-\%m-\%Y`.txt
77

88
# Donors
9-
#0 1 * * * php /var/www/solidarityMSP/bin/console app:inactive-donors >> /var/www/solidarityMSP/var/log/crontab-inactive-donors-`date +\%d-\%m-\%Y`.txt
9+
0 1 * * * php /var/www/solidarityMSP/bin/console app:inactive-donors >> /var/www/solidarityMSP/var/log/crontab-inactive-donors-`date +\%d-\%m-\%Y`.txt
1010
0 8 * * 1 php /var/www/solidarityMSP/bin/console app:thank-you-donors >> /var/www/solidarityMSP/var/log/crontab-thank-you-donors-`date +\%d-\%m-\%Y`.txt
1111

1212
# Cache

src/Command/InactiveDonorsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function haveNotPaidLastTransactions(UserDonor $userDonor): bool
9595
}
9696

9797
$dates[$transaction->getCreatedAt()->format('Y-m-d')] = true;
98-
if (3 == count($dates)) {
98+
if (5 == count($dates)) {
9999
return true;
100100
}
101101
}

src/Command/Transaction/CreateCommand.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4444
return Command::SUCCESS;
4545
}
4646

47+
$lastUserDonor = $this->entityManager->getRepository(UserDonor::class)->findOneBy([], ['id' => 'DESC']);
48+
$this->userDonorLastId = $lastUserDonor->getId();
49+
4750
while (true) {
4851
$userDonors = $this->getUserDonors();
4952
if (empty($userDonors)) {
@@ -85,9 +88,9 @@ public function getUserDonors(): array
8588
->innerJoin('ud.user', 'u')
8689
->andWhere('u.isActive = 1')
8790
->andWhere('u.isEmailVerified = 1')
88-
->andWhere('ud.id > :lastId')
91+
->andWhere('ud.id < :lastId')
8992
->setParameter('lastId', $this->userDonorLastId)
90-
->orderBy('ud.id', 'ASC')
93+
->orderBy('ud.id', 'DESC')
9194
->setMaxResults(100);
9295

9396
$results = $qb->getQuery()->getResult();

0 commit comments

Comments
 (0)