From a8cc627ebc044291192dd2e5f4c513e9e0bfbfd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Mon, 24 Jul 2023 02:07:37 +0200 Subject: [PATCH] fix select to avoid getting all events as upcoming/recent --- src/Repository/EventRepository.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Repository/EventRepository.php b/src/Repository/EventRepository.php index e1aa287..fbafab8 100644 --- a/src/Repository/EventRepository.php +++ b/src/Repository/EventRepository.php @@ -1,4 +1,6 @@ -where(function (Select $select) use ($from, $days) { $select->where('start', '<', (clone $from)->add(DateInterval::createFromDateString("$days days"))->format('Y-m-d H:i:s')); - $select->orWhere('end', '>', (clone $from)->sub(DateInterval::createFromDateString("$days days"))->format('Y-m-d H:i:s')); + $select->where('end', '>', $from->format('Y-m-d H:i:s')); + }); + $select->orWhere(function (Select $select) use ($from, $days) { + $select->where('end', '>', (clone $from)->sub(DateInterval::createFromDateString("$days days"))->format('Y-m-d H:i:s')); + $select->where('start', '<', $from->format('Y-m-d H:i:s')); }); } }