Repository navigation
fix(competitors): show the last 30 days instead of all time - #951
Merged
Merged
Conversation
The Competitors page read every rollup row the brand ever had, which grows daily and was nearing the 8 s statement timeout on the largest brand (6.9 s). It now reads the trailing 30 days, as Insights' 30d preset, and says so under the competitor list. The daily health report times the same window.
Its distinct-prompt counts sorted ~240k rows to disk with the default 5 MB on the largest brand's 30-day window. 5.35 s -> 4.4 s as the page runs it. Already applied to the hosted database.
gkhngyk
force-pushed
the
fix/competitors-default-30-days
branch
from
October 6, 2026 16:47
c62be13 to
dd68a40
Compare
This was referenced Oct 6, 2026
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
The Competitors page always read all-time data (
getCompetitorComparison(brand.id, { days: {} })): every rollup row the brand ever had. That set grows every day. On the largest brand it took 6.9 s against the page's 8 s statement timeout, and production logs show occasional timeouts on this read.competitors.windowLast30Days)On the largest brand this read goes from 6.9 s to 5.35 s. Most of that brand's history is recent, so the window alone helps less there than it will over time. The function's own cost is a separate follow-up: it sorts to disk with the default
work_mem.Head-to-head (#923/#942) and a date picker (#892) are unchanged.
Related issue
Related to #892, which asks for a date range control; this only changes the default.
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
Open Competitors. The list shows "Scores cover the last 30 days.", and the benchmark numbers match Insights' 30d preset for the same brand.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)🤖 Generated with Claude Code