Skip to content

Fix incident history pager window navigation#4604

Open
Misrilal-Sah wants to merge 1 commit intocachethq:developfrom
Misrilal-Sah:pr/4435-history-pager-window
Open

Fix incident history pager window navigation#4604
Misrilal-Sah wants to merge 1 commit intocachethq:developfrom
Misrilal-Sah:pr/4435-history-pager-window

Conversation

@Misrilal-Sah
Copy link
Copy Markdown

Issue link id: #4435

Description:
This adjusts timeline pagination to move by full non-overlapping windows.
Previously, previous and next links could overlap date ranges and produce confusing navigation.
The fix updates window boundaries and backward availability checks so navigation behaves predictably.

Copilot AI review requested due to automatic review settings March 31, 2026 18:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes timeline pagination on the status page so “previous”/“next” navigation moves by full, non-overlapping date windows, addressing the confusing overlap described in issue #4435.

Changes:

  • Introduces a windowSpan (daysToShow + 1) to page by full windows rather than overlapping ranges.
  • Extracts and reuses oldestDateInWindow for clearer window boundary calculations.
  • Updates the backward paging availability check to align with the window boundary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

->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)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withCanPageBackward(...) ignores the same visibility constraint used for $allIncidents (visible >= $incidentVisibility). For unauthenticated users this can surface a "previous" link even when only non-visible incidents exist before the current window, leading to navigation into empty/hidden pages. Consider reusing the same base query conditions (including visibility) and using ->exists() instead of ->count() > 0 to avoid a full COUNT scan.

Suggested change
->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $oldestDateInWindow->format('Y-m-d').' 00:00:00')->count() > 0)
->withCanPageBackward(Incident::notScheduled()->where('visible', '>=', $incidentVisibility)->where('created_at', '<', $oldestDateInWindow->format('Y-m-d').' 00:00:00')->exists())

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants