Skip to content
Snippets Groups Projects
Verified Commit e5a1c291 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

feat: optimize visit count calculations in HomeController

parent 9c350454
No related branches found
No related tags found
1 merge request!57Resolve "Compléter home dashboard admin avec les stats journaliers du site"
Pipeline #1014 passed
......@@ -34,9 +34,9 @@ public function index(): View
->get();
$now = now();
$totalVisitsPastTwentyFourHours = $visits->where('created_at', '>=', $now->subDay())->count();
$totalVisitsPastSevenDays = $visits->where('created_at', '>=', $now->subDays(7))->count();
$totalVisitsPastThirtyDays = $visits->where('created_at', '>=', $now->subDays(30))->count();
$totalVisitsPastTwentyFourHours = $visits->where('created_at', '>=', $now->copy()->subDay())->count();
$totalVisitsPastSevenDays = $visits->where('created_at', '>=', $now->copy()->subDays(7))->count();
$totalVisitsPastThirtyDays = $visits->where('created_at', '>=', $now->copy()->subDays(30))->count();
$totalVisitsAllTime = $visits->count();
$visitsPerDay = $visits->groupBy(fn ($visit) => Carbon::parse($visit->created_at)->format('Y-m-d'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment