From dfb8c67dd4f8509e0a9de04bbdbbe75f5d974d0d Mon Sep 17 00:00:00 2001 From: misrilal Date: Wed, 1 Apr 2026 00:00:16 +0530 Subject: [PATCH] Fix incident history pager window navigation --- app/Http/Controllers/StatusPageController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/StatusPageController.php b/app/Http/Controllers/StatusPageController.php index c4429947e787..58e362baac8e 100644 --- a/app/Http/Controllers/StatusPageController.php +++ b/app/Http/Controllers/StatusPageController.php @@ -79,11 +79,13 @@ public function showIndex() } else { $incidentDays = range(0, $daysToShow); } + $windowSpan = $daysToShow + 1; + $oldestDateInWindow = $startDate->copy()->subDays($daysToShow); $incidentVisibility = Auth::check() ? 0 : 1; $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->whereBetween('created_at', [ - $startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00', + $oldestDateInWindow->format('Y-m-d').' 00:00:00', $startDate->format('Y-m-d').' 23:59:59', ])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->load('updates')->groupBy(function (Incident $incident) { return app(DateFactory::class)->make($incident->is_scheduled ? $incident->scheduled_at : $incident->created_at)->toDateString(); @@ -107,9 +109,9 @@ public function showIndex() ->withDaysToShow($daysToShow) ->withAllIncidents($allIncidents) ->withCanPageForward((bool) $today->gt($startDate)) - ->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0) - ->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString()) - ->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString()); + ->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $oldestDateInWindow->format('Y-m-d').' 00:00:00')->count() > 0) + ->withPreviousDate($startDate->copy()->subDays($windowSpan)->toDateString()) + ->withNextDate($startDate->copy()->addDays($windowSpan)->toDateString()); } /**