Fix inconsistent delivery stat card counts on Deliveries page - #230
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
On the Deliveries index page, the
Successful,Failed, andPendingstat cards were computed client-side inresources/js/Pages/Deliveries/Index.vueby filteringdeliveries.data, which is only the current paginated page of results. The adjacentTotalcard, by contrast, correctly read the server-sidedeliveries.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 computessuccessful/failed/pendingcounts 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 newdeliveryCountsprop.Deliveries/Index.vuenow readssuccessfulCount/failedCount/pendingCountfromdeliveryCountsinstead of deriving them from the current page'sdataarray.router.reload({ only: [...] })) now also refetchesdeliveryCountsso it stays in sync withdeliveries.DashboardDeliveriesStatCountsTestcovering: 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 --dirtypassescomposer test(267 passed, 1 pre-existing skip)php artisan test --filter=DashboardDeliveriesStatCountsTestFixes #144