fix: Dedupe alerts by URL to prevent spam from existing duplicates #808
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
external_urlacross all perspectivesmentions_agenticdetection to require advertising contextindustry_alerts(channel_id, perspective_id)for query performanceProblem
Spam from duplicates: The same Adweek article was being posted 5+ times because it appeared in multiple RSS feeds. Each feed created a duplicate perspective before the cross-feed deduplication fix.
Irrelevant content: Articles about general AI (ChatGPT updates, OpenAI agents) were being flagged as relevant because they mentioned "AI agent" even without any advertising context.
Solution
Alert deduplication
Changed the NOT EXISTS subquery from checking
perspective_idto checking if ANY perspective with the sameexternal_urlhas been alerted to that channel.Content relevance
Tightened
checkMentionsAgentic()to require BOTH:agentic,ai agent,autonomous agent, etc.advertising,programmatic,media buy,dsp,campaign, etc.Before: Article about "OpenAI's new AI agent" →
mentions_agentic = trueAfter: Same article →
mentions_agentic = false(no advertising context)Test plan
🤖 Generated with Claude Code