mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-23 03:46:10 +01:00
Improve determination of "end" in db constraints
Some dates might not have an end date, but only start. Those should be respected.
This commit is contained in:
parent
26cc0d3f8c
commit
da87dc7644
1 changed files with 12 additions and 1 deletions
|
@ -65,7 +65,18 @@ class DateRepository extends Repository
|
|||
$constraints['starts'] = $query->greaterThanOrEqual('start', $demand->getStart());
|
||||
}
|
||||
if ($demand->getEnd() != null) {
|
||||
$constraints['ends'] = $query->lessThanOrEqual('end', $demand->getEnd());
|
||||
// Dates might have end of 0 if only start exists.
|
||||
// This is respected to take start as end date.
|
||||
$constraints['ends'] = $query->logicalOr([
|
||||
$query->logicalAnd([
|
||||
$query->lessThanOrEqual('end', $demand->getEnd()),
|
||||
$query->greaterThan('end', 0)
|
||||
]),
|
||||
$query->logicalAnd([
|
||||
$query->equals('end', 0),
|
||||
$query->lessThanOrEqual('start', $demand->getEnd())
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($demand->getStart() === null && $demand->getEnd() === null) {
|
||||
|
|
Loading…
Reference in a new issue