Skip to content

Commit

Permalink
Fixed data calculation for today date range filter (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgbaybay authored Jan 17, 2025
1 parent 3885219 commit a757f95
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/Report/ApiRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public function getResults(SanitizerInterface $sanitizedParams)
// depending on the date range selected.
$fromDt = $sanitizedParams->getDate('fromDt');
$toDt = $sanitizedParams->getDate('toDt');
$currentDate = Carbon::now()->startOfDay();

// If toDt is current date then make it current datetime
if ($toDt->format('Y-m-d') == $currentDate->format('Y-m-d')) {
$toDt = Carbon::now();
}

$type = $sanitizedParams->getString('type');

Expand Down
6 changes: 6 additions & 0 deletions lib/Report/DisplayAlerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public function getResults(SanitizerInterface $sanitizedParams)
// depending on the date range selected.
$fromDt = $sanitizedParams->getDate('fromDt');
$toDt = $sanitizedParams->getDate('toDt');
$currentDate = Carbon::now()->startOfDay();

// If toDt is current date then make it current datetime
if ($toDt->format('Y-m-d') == $currentDate->format('Y-m-d')) {
$toDt = Carbon::now();
}

$metadata = [
'periodStart' => Carbon::createFromTimestamp($fromDt->toDateTime()->format('U'))
Expand Down
6 changes: 6 additions & 0 deletions lib/Report/SessionHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ public function getResults(SanitizerInterface $sanitizedParams)
// depending on the date range selected.
$fromDt = $sanitizedParams->getDate('fromDt');
$toDt = $sanitizedParams->getDate('toDt');
$currentDate = Carbon::now()->startOfDay();

// If toDt is current date then make it current datetime
if ($toDt->format('Y-m-d') == $currentDate->format('Y-m-d')) {
$toDt = Carbon::now();
}

$metadata = [
'periodStart' => Carbon::createFromTimestamp($fromDt->toDateTime()->format('U'))
Expand Down
8 changes: 6 additions & 2 deletions lib/Report/TimeDisconnectedSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,19 @@ public function getResults(SanitizerInterface $sanitizedParams)
$onlyLoggedIn = $sanitizedParams->getCheckbox('onlyLoggedIn') == 1;
$groupBy = $sanitizedParams->getString('groupBy');

$currentDate = Carbon::now()->startOfDay();

//
// From and To Date Selection
// --------------------------
// The report uses a custom range filter that automatically calculates the from/to dates
// depending on the date range selected.
$fromDt = $sanitizedParams->getDate('fromDt');
$toDt = $sanitizedParams->getDate('toDt');
$currentDate = Carbon::now()->startOfDay();

// If toDt is current date then make it current datetime
if ($toDt->format('Y-m-d') == $currentDate->format('Y-m-d')) {
$toDt = Carbon::now();
}

// Get an array of display groups this user has access to
$displayGroupIds = [];
Expand Down

0 comments on commit a757f95

Please sign in to comment.