feat: default statistics filter to a rolling 12-month window
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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