From 9ae74be1c9cb75faf6ba90e96ac9f162f9d9f12d Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Fri, 23 Feb 2024 16:48:12 +0100 Subject: [PATCH] [BUGFIX] Set endtime to now for timefilter in shortmode After this commit, that fixes when filter is set to last month in Analysis/Dashboard view --- Classes/Domain/Model/Transfer/FilterDto.php | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Classes/Domain/Model/Transfer/FilterDto.php b/Classes/Domain/Model/Transfer/FilterDto.php index 20f47325..60f08fc4 100644 --- a/Classes/Domain/Model/Transfer/FilterDto.php +++ b/Classes/Domain/Model/Transfer/FilterDto.php @@ -523,15 +523,20 @@ public function getStartTimeForFilter(bool $shortmode = false): DateTime /** * Get a stop datetime for period filter * + * @param bool $shortmode * @return DateTime * @throws Exception */ - public function getEndTimeForFilter(): DateTime + public function getEndTimeForFilter(bool $shortmode = false): DateTime { if ($this->getTimeFrom()) { $time = $this->getTimeToDateTime(); } else { - $time = $this->getEndTimeFromTimePeriod(); + if ($shortmode === false || $this->isShortMode() === false) { + $time = $this->getEndTimeFromTimePeriod(); + } else { + $time = $this->getEndTimeFromTimePeriodShort(); + } } return $time; } @@ -604,6 +609,15 @@ protected function getStartTimeFromTimePeriodShort(): DateTime return $this->getStartTimeFromTimePeriod(); } + /** + * @return DateTime + * @throws Exception + */ + protected function getEndTimeFromTimePeriodShort(): DateTime + { + return new DateTime(); + } + /** * Example return values * [ @@ -661,7 +675,7 @@ public function getIntervals(): array protected function getStartIntervals(): array { $start = $this->getStartTimeForFilter(true); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $deltaSeconds = $end->getTimestamp() - $start->getTimestamp(); if ($deltaSeconds <= 86400) { // until 1 day return ['intervals' => $this->getHourIntervals(), 'frequency' => 'hour']; @@ -686,7 +700,7 @@ protected function getStartIntervals(): array protected function getHourIntervals(): array { $start = $this->getStartTimeForFilter(true); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $interval = []; for ($hour = clone $start; $hour < $end; $hour->modify('+1 hour')) { $interval[] = clone $hour; @@ -702,7 +716,7 @@ protected function getHourIntervals(): array protected function getDayIntervals(): array { $start = DateUtility::getDayStart($this->getStartTimeForFilter(true)); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $interval = []; for ($day = clone $start; $day < $end; $day->modify('+1 day')) { $interval[] = clone $day; @@ -718,7 +732,7 @@ protected function getDayIntervals(): array protected function getWeekIntervals(): array { $start = DateUtility::getPreviousMonday($this->getStartTimeForFilter(true)); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $interval = []; for ($week = clone $start; $week < $end; $week->modify('+1 week')) { $interval[] = clone $week; @@ -734,7 +748,7 @@ protected function getWeekIntervals(): array protected function getMonthIntervals(): array { $start = DateUtility::getStartOfMonth($this->getStartTimeForFilter(true)); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $interval = []; for ($month = clone $start; $month < $end; $month->modify('+1 month')) { $interval[] = clone $month; @@ -750,7 +764,7 @@ protected function getMonthIntervals(): array protected function getYearIntervals(): array { $start = DateUtility::getStartOfYear($this->getStartTimeForFilter(true)); - $end = $this->getEndTimeForFilter(); + $end = $this->getEndTimeForFilter(true); $interval = []; for ($year = clone $start; $year < $end; $year->modify('+1 year')) { $interval[] = clone $year;