@@ -72,19 +72,21 @@ public function findScheduledSubscriptions(): array
7272 $ qb ->andWhere ('s.scheduledDate < :date ' );
7373 $ qb ->setParameter ('date ' , new \DateTime ());
7474 $ qb ->andWhere ('s.fulfilledDate IS NULL ' );
75+ $ qb ->andWhere ('q.migratedAt IS NULL ' );
7576
7677 return $ qb ->getQuery ()->getResult ();
7778 }
7879
7980 public function findScheduledSubscriptionsForMigration (): array
8081 {
8182 $ qb = $ this ->createQueryBuilder ('q ' );
82- $ qb ->andWhere ('q.state IN (:states) ' );
83- $ qb ->setParameter ('states ' , [ MollieSubscriptionInterface::STATE_ACTIVE , MollieSubscriptionInterface:: STATE_PROCESSING ] );
83+ $ qb ->andWhere ('q.state = :state ' );
84+ $ qb ->setParameter ('state ' , MollieSubscriptionInterface::STATE_ACTIVE );
8485 $ qb ->leftJoin ('q.schedules ' , 's ' );
8586 $ qb ->andWhere ('s.scheduledDate < :date ' );
8687 $ qb ->setParameter ('date ' , new \DateTime ());
8788 $ qb ->andWhere ('s.fulfilledDate IS NULL ' );
89+ $ qb ->andWhere ('q.migratedAt IS NULL ' );
8890
8991 return $ qb ->getQuery ()->getResult ();
9092 }
@@ -96,6 +98,7 @@ public function findProcessableSubscriptions(): array
9698 $ qb ->setParameter ('state ' , MollieSubscriptionInterface::STATE_PROCESSING );
9799 $ qb ->andWhere ('q.processingState = :processingState ' );
98100 $ qb ->setParameter ('processingState ' , MollieSubscriptionInterface::PROCESSING_STATE_PENDING );
101+ $ qb ->andWhere ('q.migratedAt IS NULL ' );
99102
100103 return $ qb ->getQuery ()->getResult ();
101104 }
@@ -104,8 +107,11 @@ public function iterateToMigrate(int $batchSize): iterable
104107 {
105108 $ qb = $ this ->createQueryBuilder ('q ' );
106109 $ qb ->andWhere ('q.migratedAt IS NULL ' );
107- $ qb ->andWhere ('q.state != :paused ' );
108- $ qb ->setParameter ('paused ' , MollieSubscriptionInterface::STATE_PAUSED );
110+ $ qb ->andWhere ('q.state NOT IN (:excludedStates) ' );
111+ $ qb ->setParameter ('excludedStates ' , [
112+ MollieSubscriptionInterface::STATE_PAUSED ,
113+ MollieSubscriptionInterface::STATE_PROCESSING ,
114+ ]);
109115 $ qb ->setMaxResults ($ batchSize );
110116
111117 return $ qb ->getQuery ()->toIterable ();
0 commit comments