From a968b776b505b1911838d843dafcbfe9b468e4ef Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Sat, 10 Jan 2026 07:41:42 -0500 Subject: [PATCH] fix: exclude free email providers from related domains in domain health MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gmail.com and other free email providers were appearing in the "Related Organizations" section of the domain health dashboard, incorrectly grouping unrelated organizations together just because some of their users had Gmail addresses. Added filtering to the relatedDomainsResult query to exclude: - Hardcoded free email domains (gmail.com, yahoo.com, hotmail.com, etc.) - Admin-managed personal domains from the database 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .changeset/block-gmail-corp-domain.md | 4 ++++ server/src/routes/admin/domains.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/block-gmail-corp-domain.md diff --git a/.changeset/block-gmail-corp-domain.md b/.changeset/block-gmail-corp-domain.md new file mode 100644 index 0000000000..aefb92e1e1 --- /dev/null +++ b/.changeset/block-gmail-corp-domain.md @@ -0,0 +1,4 @@ +--- +--- + +Fix domain health page to exclude free email providers (gmail.com, etc.) from "Related Organizations" section diff --git a/server/src/routes/admin/domains.ts b/server/src/routes/admin/domains.ts index 7aeaa01f3e..3613f6d8eb 100644 --- a/server/src/routes/admin/domains.ts +++ b/server/src/routes/admin/domains.ts @@ -1439,6 +1439,8 @@ export function setupDomainRoutes( SUBSTRING(domain FROM '([^.]+\\.[^.]+)$') as root_domain FROM org_domains WHERE domain IS NOT NULL + -- Exclude personal email domains (gmail.com, yahoo.com, admin-managed domains, etc.) + AND LOWER(SUBSTRING(domain FROM '([^.]+\\.[^.]+)$')) NOT IN (${freeEmailPlaceholders}) ), root_groups AS ( -- Group by root domain, only keep groups with multiple orgs @@ -1461,8 +1463,8 @@ export function setupDomainRoutes( ) SELECT * FROM root_groups ORDER BY org_count DESC - LIMIT $1 - `, [limit]); + LIMIT $${allExcludedDomains.length + 1} + `, [...allExcludedDomains, limit]); // 7. Similar organization names - find orgs with similar names that might be duplicates // Uses trigram similarity (requires pg_trgm extension) or simple word matching