Repository navigation
fix(traffic): exact visit counts and paginated breakdown/trend scans - #468
Merged
Merged
Conversation
getTrafficSummary and getTrafficTrend fetched their windows in single un-paginated selects: PostgREST silently caps those at 1000 rows, so on busy brands the AI-Referred Visits KPI froze at 1000 and the platform breakdown, top pages and trend chart aggregated a truncated slice — with the previous-period comparison equally wrong. Errors were also silently swallowed, rendering an empty dashboard instead of failing loudly. - Totals now come from exact count queries (head: true) — no row transfer, immune to the cap. - Breakdowns and the trend page through the window with deterministic (created_at, id) ordering, a 1000-row page size and a 50k hard ceiling, aggregating per batch via a shared scanTrafficLogs helper. - Query errors now throw instead of being ignored. getTrafficLogs was already correct (.range() + count). Closes #450
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.
Summary
getTrafficSummaryandgetTrafficTrendfetched their whole window in single un-paginated selects. PostgREST silently caps those at 1000 rows, so on busy brands the AI-Referred Visits KPI froze at 1000 and the platform breakdown, Top Landing Pages and trend chart aggregated a truncated slice — with the previous-period comparison equally wrong. The queries also swallowed errors silently (const { data } = …with no error check), rendering an empty dashboard instead of failing loudly.head: true, count: 'exact') — no row transfer, immune to the cap.scanTrafficLogshelper: deterministic(created_at, id)ordering, 1000-row pages, 50k hard ceiling, aggregated per batch (rows are never all held in memory).getTrafficLogswas already correct (.range()+ filtered count from #454) and is untouched.Related issue
Closes #450
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)