From f62809e77db81dd09fe385dc040b534738d53b6e Mon Sep 17 00:00:00 2001 From: George Bateman Date: Mon, 17 Sep 2018 11:04:50 +0100 Subject: [PATCH] Make getCurrentByPerson use performance dates. nb #386, fixes #384 --- src/Acts/CamdramBundle/Entity/ShowRepository.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Acts/CamdramBundle/Entity/ShowRepository.php b/src/Acts/CamdramBundle/Entity/ShowRepository.php index 5c097126c..e025929a2 100644 --- a/src/Acts/CamdramBundle/Entity/ShowRepository.php +++ b/src/Acts/CamdramBundle/Entity/ShowRepository.php @@ -132,12 +132,14 @@ public function getUpcomingByPerson(\DateTime $now, Person $person) public function getCurrentByPerson(\DateTime $now, Person $person) { $query = $this->createQueryBuilder('s') - ->where('s.end_at >= :now') - ->andWhere('s.start_at < :now') - ->andWhere('s.authorised_by is not null') ->join('s.roles', 'r') + ->leftJoin('s.performances', 'p') + ->where('s.authorised_by is not null') ->andWhere('r.person = :person') - ->orderBy('s.start_at', 'ASC') + ->orderBy('p.start_date', 'ASC') + ->groupBy('s.id') + ->having('MIN(p.start_date) < :now') + ->andHaving('MAX(p.end_date) >= :now') ->setParameter('person', $person) ->setParameter('now', $now) ->getQuery();