feat(monitoring): attribute SaaS citations by registrable domain
Persist host/registrable_domain/site_key on monitoring article URL aliases, populate them on desktop-publish completion, and use them in the citation pipeline to count how often SaaS-published content appears as a citation source. Expose a /citation-summary endpoint with a 7/30-day window switch and surface the new source-share metrics in the tracking dashboard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
DROP INDEX IF EXISTS idx_article_url_alias_site_key;
|
||||
DROP INDEX IF EXISTS idx_article_url_alias_domain;
|
||||
|
||||
ALTER TABLE monitoring_article_url_aliases
|
||||
DROP COLUMN IF EXISTS site_key,
|
||||
DROP COLUMN IF EXISTS registrable_domain,
|
||||
DROP COLUMN IF EXISTS host;
|
||||
@@ -0,0 +1,27 @@
|
||||
ALTER TABLE monitoring_article_url_aliases
|
||||
ADD COLUMN IF NOT EXISTS host VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS registrable_domain VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS site_key VARCHAR(255);
|
||||
|
||||
WITH parsed_aliases AS (
|
||||
SELECT
|
||||
id,
|
||||
LOWER(SPLIT_PART(SUBSTRING(original_url FROM '^[a-zA-Z][a-zA-Z0-9+.-]*://([^/?#]+)'), ':', 1)) AS parsed_host
|
||||
FROM monitoring_article_url_aliases
|
||||
)
|
||||
UPDATE monitoring_article_url_aliases alias
|
||||
SET host = COALESCE(NULLIF(alias.host, ''), parsed_aliases.parsed_host),
|
||||
registrable_domain = COALESCE(NULLIF(alias.registrable_domain, ''), parsed_aliases.parsed_host),
|
||||
site_key = COALESCE(NULLIF(alias.site_key, ''), parsed_aliases.parsed_host)
|
||||
FROM parsed_aliases
|
||||
WHERE alias.id = parsed_aliases.id
|
||||
AND parsed_aliases.parsed_host IS NOT NULL
|
||||
AND parsed_aliases.parsed_host <> '';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_article_url_alias_domain
|
||||
ON monitoring_article_url_aliases(tenant_id, registrable_domain)
|
||||
WHERE registrable_domain IS NOT NULL AND registrable_domain <> '';
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_article_url_alias_site_key
|
||||
ON monitoring_article_url_aliases(tenant_id, site_key)
|
||||
WHERE site_key IS NOT NULL AND site_key <> '';
|
||||
Reference in New Issue
Block a user