feat: default statistics filter to a rolling 12-month window
This commit is contained in:
1 parent
410c99a9b0
commit
f6667dcfc7
10 files changed
+114
-36
No files matched your search
@@ -32,4 +32,27 @@ class StatisticsFilterDto extends AbstractFilterDto
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The lower bound actually applied to a query: the picked date, or a rolling
|
||||
* 12-month window ending today when nothing is picked.
|
||||
*
|
||||
* The default lives here rather than in a nullable property so that
|
||||
* AbstractFilterDto::isActive() still sees a fresh instance as "not filtered"
|
||||
* (it compares properties with !==, which no two DateTimeImmutable share).
|
||||
*/
|
||||
public function getEffectiveDateFrom(): \DateTimeImmutable
|
||||
{
|
||||
return $this->dateFrom ?? (new \DateTimeImmutable('today'))->modify('-12 months');
|
||||
}
|
||||
|
||||
public function getEffectiveDateTo(): \DateTimeImmutable
|
||||
{
|
||||
return $this->dateTo ?? new \DateTimeImmutable('today 23:59:59');
|
||||
}
|
||||
|
||||
public function isUsingDefaultRange(): bool
|
||||
{
|
||||
return null === $this->dateFrom && null === $this->dateTo;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user