Skip to content

Fix inconsistent delivery stat card counts on Deliveries page - #230

Merged
morcen merged 1 commit into
mainfrom
fix/issue-144-delivery-stat-cards
Sep 20, 2026
Merged

morcen merged 1 commit into
mainfrom
fix/issue-144-delivery-stat-cards

Conversation

@morcen

@morcen morcen commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

What was broken

On the Deliveries index page, the Successful, Failed, and Pending stat cards were computed client-side in resources/js/Pages/Deliveries/Index.vue by filtering deliveries.data, which is only the current paginated page of results. The adjacent Total card, by contrast, correctly read the server-side deliveries.total.

On any account with more than one page of deliveries, this made the four stat cards internally inconsistent — e.g. "Total: 240" next to "Successful: 11 / Failed: 3 / Pending: 1", which sums to the page size rather than the true total. This misleads users about their actual delivery success/failure rate.

What changed

  • DashboardController::deliveries() now computes successful/failed/pending counts server-side, using the same filtered query (ownership, status, endpoint, event, date-range filters) as the paginated list, before pagination is applied. These are passed to the page as a new deliveryCounts prop.
  • Deliveries/Index.vue now reads successfulCount/failedCount/pendingCount from deliveryCounts instead of deriving them from the current page's data array.
  • The "Refresh" button's partial reload (router.reload({ only: [...] })) now also refetches deliveryCounts so it stays in sync with deliveries.
  • Added DashboardDeliveriesStatCountsTest covering: counts reflecting all matching records (not just the current page), counts respecting active filters, and counts being scoped to the authenticated user's own deliveries.

Test plan

  • vendor/bin/pint --dirty passes
  • Full suite passes: composer test (267 passed, 1 pre-existing skip)
  • New test file passes on its own: php artisan test --filter=DashboardDeliveriesStatCountsTest

Fixes #144

The Successful/Failed/Pending stat cards on the Deliveries index page
were computed client-side from the current paginated page of results,
while the adjacent Total card read the true server-side total. Any
account with more than one page of deliveries saw internally
inconsistent stats (e.g. Total: 240 next to counts that only summed to
the page size), misleading users about their actual delivery success
rate.

Compute successful/failed/pending counts server-side in
DashboardController::deliveries() using the same filtered query as the
paginated list, and pass them to the page as a new deliveryCounts prop
instead of deriving them from deliveries.data. Also include
deliveryCounts in the partial reload triggered by the Refresh button so
the counts stay in sync with the delivery list.

Fixes #144
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.

Deliveries page stat cards (Successful/Failed/Pending) only count the current page, while the Total card counts all records

1 participant