Skip to content

fix(citations): count the Domains tab within the selected source scope - #1218

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/citations-domains-tab-count
Oct 20, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/citations-domains-tab-count

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The Citations page's Domains tab now counts the domains in the selected source scope.

The bug. The tab label read data.totals.domains, which counts every cited domain whatever the scope (Brand / Competitors / Third-Party / All). The page opens on Brand, so it read e.g. "Domains (754)" above a table listing only the brand's own domains. That number belongs to All.

The fix.

  • The label now counts filteredDomainRows, the rows its table lists. The domain list isn't capped, so this is the scope's full count, and All still shows the total.
  • The URLs label was already scoped on the server (Citations: scoping the URL tab filters inside the 2,000-row cap, so it under-reports #745) and is unchanged.
  • Small cleanup: the scope check that the Domains and URLs rows each repeated as a switch is now inSourceScope(category, scope) in lib/citations/scope.ts, next to scopeDomainArgs, with a test.

Related issue

None. A user report ("Domains shows 754 on open, which is All's number; it should only show on All").

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open /dashboard/citations. It opens on Brand, and the Domains count equals the rows in its table.
  2. Click Competitors, Third-Party and All. Each time, the Domains and URLs counts match their tables, and All shows the total.

I checked this locally with temporary citations (since deleted):

Scope Domains URLs
Brand 1 2
Competitors 1 1
Third-Party 3 3
All 5 6

The table rows matched each count, in light and dark themes. scope.test.ts covers inSourceScope for every scope.

Not in this PR: the Unique Domains KPI counts every domain, while its "N unique URLs" line follows the scope. It could read "5 domains · 2 URLs" on Brand. I can follow up if you want them consistent.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run: yarn test (1,695 pass) and yarn build (with the CI placeholders).

🤖 Generated with Claude Code

The Domains tab showed every cited domain (totals.domains) whatever the scope, so the page, which opens on Brand, read Domains (754) over a table of the brand's own domains. The tab now counts the rows its table lists, so the full number shows on All only. The scope check the Domains and URLs rows each repeated is inSourceScope in lib/citations/scope.ts, with a test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk A small fix: the Domains tab counted every cited domain whatever the scope, so the page, which opens on Brand, showed All's number (754) above the brand's own domains. The tab now counts the rows its table lists. The duplicated scope switch is now inSourceScope in lib/citations/scope.ts, with a test. One question in the description: should the Unique Domains KPI's URL line follow the scope like the tabs, or stay unscoped like the KPI?

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on main: web tests pass. totals.domains was already rows.length, so All keeps the same number, and the other scopes now match their tables. A follow-up to scope the Unique Domains KPI the same way would be welcome.

@gkhngyk
gkhngyk merged commit fea0007 into ansvisor:main Oct 20, 2026
6 checks passed
gkhngyk pushed a commit that referenced this pull request Oct 20, 2026
…ce scope (#1249)

The Unique Domains card counted every cited domain whatever the scope,
while the unique URLs under it are counted within the scope (#745) and
the Domains tab counts its rows (#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: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants