Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Reporting: time connected summary report does not work with Today as the range #2856

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
// 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 Expand Up @@ -364,7 +370,7 @@

$rows = [];
foreach ($this->store->select($sql, $params) as $row) {
$sessionRecord = $this->logFactory->createEmpty()->hydrate($row, ['htmlStringProperties' => ['message']]);

Check warning on line 373 in lib/Report/SessionHistory.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 122 characters
$duration = isset($row['lastUsedTime'])
? date_diff(date_create($row['startTime']), date_create($row['lastUsedTime']))->format('%H:%I:%S')
: null;
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 @@
$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 Expand Up @@ -549,7 +553,7 @@

// Calculate the average values
$displayGroup['avgTimeConnected'] = round($displayGroup['timeConnected'] / $displayGroup['count'], 2);
$displayGroup['avgTimeDisconnected'] = round($displayGroup['timeDisconnected'] / $displayGroup['count'], 2);

Check warning on line 556 in lib/Report/TimeDisconnectedSummary.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 124 characters

$data[] = $displayGroup;
}
Expand Down
Loading