fix select to avoid getting all events as upcoming/recent
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good

This commit is contained in:
Bence Pőcze 2023-07-24 02:07:37 +02:00 committed by Gitea
parent 0d6d152b82
commit a8cc627ebc
Signed by: Gitea
GPG Key ID: 7B89B83EED9AD2C6

View File

@ -1,4 +1,6 @@
<?php namespace RVR\Repository;
<?php
namespace RVR\Repository;
use Container;
use DateTime;
@ -102,7 +104,11 @@ class EventRepository
{
$select->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'));
});
}
}