You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(promo-codes): split discover query into targeted per-subtype DQL
getDiscoverableByEmailForSummit loaded ALL 6 discoverable subtypes for
the entire summit, then filtered in PHP — O(all codes) hydrations.
Split into two focused methods:
- getDomainAuthorizedDiscoverableForSummit: fetches only the 2 DA types,
filters by email domain in PHP (unavoidable pattern match)
- getEmailLinkedDiscoverableForSummit: 4 DQL queries (one per Member/
Speaker × Promo/Discount subtype) push the email filter into the WHERE
clause, including the MemberPromoCodeTrait owner-fallback and the
PresentationSpeaker member/registration_request two-hop chain
Both methods add isLive() date filtering in DQL (:now parameter),
matching the codebase convention from DoctrineSummitRepository.
The facade method delegates to both and merges, preserving the existing
caller contract (discoverPromoCodes and its exhaustion/quota logic are
untouched).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
$now = new \DateTime('now', new \DateTimeZone('UTC'));
682
689
690
+
$qb = $em->createQueryBuilder();
683
691
$qb->select('e')
684
692
->from($this->getBaseEntity(), 'e')
685
-
->leftJoin('e.summit', 's')
693
+
->join('e.summit', 's')
686
694
->where('s.id = :summit_id')
687
-
->andWhere("(e INSTANCE OF {$daDiscountClass} OR e INSTANCE OF {$daPromoClass} OR e INSTANCE OF {$memberPromoClass} OR e INSTANCE OF {$memberDiscountClass} OR e INSTANCE OF {$speakerPromoClass} OR e INSTANCE OF {$speakerDiscountClass})")
688
-
->setParameter('summit_id', $summit->getId());
695
+
->andWhere(
696
+
'(e INSTANCE OF :da_promo OR e INSTANCE OF :da_discount)'
697
+
)
698
+
->andWhere(
699
+
'e.valid_since_date IS NULL OR e.valid_until_date IS NULL '
700
+
. 'OR (:now >= e.valid_since_date AND :now <= e.valid_until_date)'
0 commit comments