Skip to content

fix: check organizations.email_domain when looking up domains for prospects#730

Merged
bokelley merged 1 commit into
mainfrom
bokelley/fix-tryclassify-display
Jan 12, 2026
Merged

fix: check organizations.email_domain when looking up domains for prospects#730
bokelley merged 1 commit into
mainfrom
bokelley/fix-tryclassify-display

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • Fixed prospect discovery endpoints to check both organization_domains table AND organizations.email_domain column when looking up domains
  • 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

Problem

Domains like tryclassify.com were appearing as new prospects even though they belong to existing accounts (Classify). This happened because:

  1. The account had email_domain set on the organizations table
  2. But the domain wasn't in the organization_domains table (either because it was created before that table existed, or the sync failed)
  3. The prospect discovery code only checked organization_domains

Solution

Updated the SQL queries in /api/admin/slack/domains and /api/admin/email/domains to check both locations:

SELECT COALESCE(LOWER(od.domain), LOWER(o.email_domain)) as domain, ...
FROM organizations o
LEFT JOIN organization_domains od ON ...
WHERE od.domain IS NOT NULL OR LOWER(o.email_domain) = ANY($1)

Also added tools to identify and fix these sync issues via the domain-health dashboard.

Test plan

  • Build passes
  • All 187 tests pass
  • Manually tested domain-health and domain-health/sync endpoints via curl
  • Code review addressed (input validation, case normalization)

🤖 Generated with Claude Code

…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>
@bokelley bokelley merged commit bb150b6 into main Jan 12, 2026
6 checks passed
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.

1 participant