feat: default statistics filter to a rolling 12-month window

This commit is contained in:
2026-09-01 09:45:53 +02:00
parent 410c99a9b0
commit f6667dcfc7
10 changed files with 114 additions and 36 deletions
@@ -35,8 +35,8 @@ class ApplicationsByDestinationController extends AbstractController
}
$statistics = $this->applicationRepository->getApplicationsByDestination(
$filterDto->getDateFrom(),
$filterDto->getDateTo(),
$filterDto->getEffectiveDateFrom(),
$filterDto->getEffectiveDateTo(),
);
return $this->render('administrative/statistics/applications_by_destination.html.twig', [
@@ -35,8 +35,8 @@ class FeedbackByDestinationController extends AbstractController
}
$statistics = $this->dispositionRepository->getFeedbackStatisticsByNormalizedHotelCode(
$filterDto->getDateFrom(),
$filterDto->getDateTo(),
$filterDto->getEffectiveDateFrom(),
$filterDto->getEffectiveDateTo(),
);
return $this->render('administrative/statistics/feedback_by_destination.html.twig', [
@@ -35,8 +35,8 @@ class FeedbackRatingsByDestinationController extends AbstractController
}
$statistics = $this->feedbackRepository->getAverageRatingsByDestinationAndFeedbackSet(
$filterDto->getDateFrom(),
$filterDto->getDateTo(),
$filterDto->getEffectiveDateFrom(),
$filterDto->getEffectiveDateTo(),
);
return $this->render('administrative/statistics/feedback_ratings_by_destination.html.twig', [
@@ -35,8 +35,8 @@ class FeedbackRatingsController extends AbstractController
}
$statistics = $this->feedbackRepository->getAverageRatingsByQuestionAndFeedbackSet(
$filterDto->getDateFrom(),
$filterDto->getDateTo(),
$filterDto->getEffectiveDateFrom(),
$filterDto->getEffectiveDateTo(),
);
// Prepare chart data for each feedback set
+23
View File
@@ -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;
}
}