Repository navigation
fix(citations): count the Unique Domains KPI within the selected source scope - #1249
Conversation
…ce scope The Unique Domains card counted every cited domain whatever the scope, while the unique URLs under it are counted within the scope (ansvisor#745) and the Domains tab counts its rows (ansvisor#1218). On Brand it could read 3 domains over 0 URLs. It now counts the domains in the selected scope, the same rows the Domains tab lists; All keeps its number. The page's first test pins it for Brand, Third party and All. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk the follow-up you asked for on #1218: Unique Domains now counts the domains in the selected scope, the Domains tab's rows, beside the already-scoped URL count. A question before I go further: Total Citations and Avg citations per result still count every source, while the card between them is now scoped. Should they follow the scope too? Total Citations could sum the scoped rows' Side note: on the dev DB, |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. The domain rows come back whole and pages are cut in the browser, so filteredDomainRows.length is the full count in the scope. On All it equals totals.domains, as the description says. Thanks for the page's first test.
Summary
Follow-up from #1218's approval: "A follow-up to scope the Unique Domains KPI the same way would be welcome."
The Unique Domains card counted every cited domain (
totals.domains) whatever the source scope. Two numbers beside it were already scoped:totals.urls, counted within the scope since Citations: scoping the URL tab filters inside the 2,000-row cap, so it under-reports #745);So on Brand, which the page opens on, the card could read "3 unique domains · 0 unique URLs".
The card now counts the domains in the selected scope:
filteredDomainRows.length, the same rows the Domains tab lists (inSourceScope). On All the number is unchanged, sincetotals.domainsisrows.length.The page gets its first test (
citations/page.test.tsx). It renders the page with a mocked overview of five domains, two of them the brand's, and checks the card on Brand (2), Third party (2) and All (5), each beside the server's URL count.Total Citations and Avg citations per result still count all sources; see my comment below.
Related issue
Follow-up to #1218.
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
On the dev data (three cited domains, all third-party): Brand 0 · 0 URLs, Third-Party 3 · 3, All 3 · 3. Before, Brand read 3 · 0. The new tests fail on the old line for Brand and Third party, and pass now. I checked it in light and dark mode, at 1440 and 1024 px.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)yarn test(1794) andyarn buildpass too.🤖 Generated with Claude Code