Skip to content

Commit

Permalink
[BUGFIX] Set endtime to now for timefilter in shortmode
Browse files Browse the repository at this point in the history
After this commit, that fixes when filter is set to last month in Analysis/Dashboard view
  • Loading branch information
einpraegsam committed Feb 23, 2024
1 parent 94a8a62 commit 9ae74be
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions Classes/Domain/Model/Transfer/FilterDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
* [
Expand Down Expand Up @@ -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'];
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 9ae74be

Please sign in to comment.