Skip to content

Citations: scoping the URL tab filters inside the 2,000-row cap, so it under-reports #745

Closed

Description

@gkhngyk

Problem

The URL tab under-reports whenever a source scope is selected.

Two changes that are each correct on their own combine badly:

The scope therefore filters within the global top 2,000. A brand whose competitors are cited rarely can select Competitors and see almost nothing, while competitor URLs exist in the data and would have appeared before the cap landed.

The Domains tab is unaffected — domains are returned uncapped, all 20,366 of them for that brand, so filtering them after the rollup is exact.

Nothing is wrong with either change. The cap arrived a day before the scope filter, and neither knows about the other.

Why it is quiet

The pager reports the filtered count, so the tab reads as complete: "12 of 12" rather than "12 of however many exist". A reader has no way to tell the difference between this brand has twelve competitor URLs and twelve of this brand's competitor URLs happened to rank in the global top two thousand.

Fix

Teach citations_urls about the scope so the cap applies inside it — the top 2,000 competitor URLs rather than the competitors among the top 2,000 URLs.

The obstacle is that a category is not a property the database knows. classifyDomain decides it from the brand's own domain list and its competitor list, both of which live in brand_domains and competitors. Two ways to close that:

  • Pass the lists in. The function takes brand domains and competitor domains as arrays and classifies with a suffix match, mirroring matchesSuffix. Keeps one definition of the rule in SQL and one in TypeScript, which will drift.
  • Resolve the scope to a domain list in the caller. The action already classifies every domain for the Domains tab — it can hand citations_urls the domains that survive the scope and let the function filter on domain = any(...). One definition of the rule, in TypeScript, and the function stays ignorant of what a competitor is.

The second is the better shape. The domain list can be large (20,366 for the largest brand), so it has to travel in the request body rather than the query string — the mistake #741 already paid for once.

Acceptance criteria

  • Selecting a scope returns the top N URLs within that scope, not the scope's share of the top N overall.
  • The reported total reflects the scope, so the tab never implies it is showing everything when it is not.
  • The Domains tab is unchanged.
  • No new definition of what counts as a brand or competitor domain — the existing one is reused.

Activity

  1. added
    bug
    citations
    on Aug 20, 2026
  2. self-assigned this
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugcitations

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions