Repository navigation
fix(insights): show at least five brands on the leaderboard, yours always among them - #1352
Merged
gkhngyk merged 1 commit intoOct 22, 2026
Merged
Conversation
…ways among them The leaderboard showed ranks 1 and 2 and the brands around yours, so a brand near the top saw three rows (rank 2 at 24h on a board of eight). It now shows at least five, filling up from the top, with your row always there; a single brand between two shown is listed rather than folded into "1 more". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
@gkhngyk this is a small Insights fix from the feedback round. On production, Ansvisor at 24h is rank 2 of 8 and its leaderboard showed only three rows. It now shows at least five, filled from the top, with your row always included. Only the line-picking function and its tests change. |
This was referenced Oct 22, 2026
gkhngyk
approved these changes
Oct 22, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. I checked leaderboardLines (web/src/lib/insights-summary.ts:179-197) against the edge cases:
- Near the top, or last. The fill loop always ends: past five brands it only adds indexes below
count. Your row stays in, andhiddenmatches what "Show all" adds. - Single gaps. Filling a single gap only narrows gaps, so no "1 more" line can appear. The cases
20/4,6/5and8/7hold, and the old20/5case still gives1, 2, 2 more, 5, 6, 7. - Ties.
getCompetitorComparisonsorts by score, then mentions. JS sort is stable and your brand is pushed first, so it wins exact ties. The board only indexes that order, so nothing changes here. - Zero mentions. A competitor that was tracked but never mentioned still has rollup rows. It is listed at the bottom (score
—) and counts toward the five. Only a competitor with no tracked answers yet is absent, as the description says. - Fewer than five competitors. With five brands or fewer, the board lists everyone, as before.
There is no SQL or RPC change.
Tested on top of main together with #1339–#1341, #1352 and #1337: web and server tests, tsc, lint and Prettier pass.
9 of 12 tasks
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
Content Editor feedback item 13 (Insights): when competitors are added, the leaderboard should show at least five rows, always with the brand's own rank.
Cause.
leaderboardLinesshowed ranks 1 and 2 plus the brands directly ahead of and behind yours. Near the top those overlap: on production, Ansvisor is rank 2 of 8 at 24h and its leaderboard showed three rows (Profound, Ansvisor, Semrush). At 30d it is rank 6, and five rows showed.Fix (
lib/insights-summary.ts):The component is unchanged; it renders
leaderboardLines.Related issue
Content Editor feedback round (no issue).
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
yarn test src/lib/insights-summary.test.tscovers the cases above.The demo org has only four brands with data, so the longer board can't be shown locally. Adding competitors without data doesn't list them.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(2630 tests pass) andyarn build.🤖 Generated with Claude Code