Skip to content

Commit

Permalink
Fixed login duration chart to properly show historical data.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Aug 31, 2024
1 parent c6c1c6a commit c57477a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Admin/Services/SiteStatisticsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,19 @@ private function getRange(int $days): void {
for ($i = 0; $i <= $days; $i++) {
$date = $startDate->copy()->addDays($i)->format('Y-m-d');
$daysLabels[] = $date;
$dailyDurations[] = 0;
$dailyDurations[$date] = 0;
}

foreach ($durations as $duration) {
$dailyDurations[] += $duration->duration_in_seconds / 60;
$dateKey = Carbon::parse($duration->logged_in_at)->format('Y-m-d');
if (isset($dailyDurations[$dateKey])) {
$dailyDurations[$dateKey] += $duration->duration_in_seconds / 60;
}
}

$this->labels = $daysLabels;
$this->data = array_values($dailyDurations);
}


}

0 comments on commit c57477a

Please sign in to comment.