fix: check organizations.email_domain when looking up domains for prospects#730
Merged
Conversation
…spects The prospect discovery endpoints were only checking organization_domains table, missing domains that exist only in organizations.email_domain. This caused domains like tryclassify.com to appear as new prospects even though they belong to existing accounts. Changes: - Updated slack/domains and email/domains endpoints to check BOTH organization_domains table AND organizations.email_domain column - Added case normalization (lowercase) for consistent domain matching - Added domain_sync_issues to domain-health endpoint to identify orgs where email_domain is set but not in organization_domains - Added POST /api/admin/domain-health/sync endpoint to fix sync issues - Added input validation for org_id parameter in sync endpoint 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
organization_domainstable ANDorganizations.email_domaincolumn when looking up domainsdomain_sync_issuesto domain-health endpoint to identify orgs where email_domain is set but not in organization_domainsPOST /api/admin/domain-health/syncendpoint to fix sync issuesProblem
Domains like
tryclassify.comwere appearing as new prospects even though they belong to existing accounts (Classify). This happened because:email_domainset on theorganizationstableorganization_domainstable (either because it was created before that table existed, or the sync failed)organization_domainsSolution
Updated the SQL queries in
/api/admin/slack/domainsand/api/admin/email/domainsto check both locations:Also added tools to identify and fix these sync issues via the domain-health dashboard.
Test plan
🤖 Generated with Claude Code