Skip to content

fix: use correct entity field names in domain provider stats query - #49

Merged
andrewstech merged 1 commit into
mainfrom
fix/domain-provider-stats-wrong-domain-field
Oct 23, 2026
Merged

andrewstech merged 1 commit into
mainfrom
fix/domain-provider-stats-wrong-domain-field

Conversation

@christopher-od

Copy link
Copy Markdown
Contributor

Bug

Active Subdomains, Pending Requests, New (7 days), and managed DNS Records all showed 0 despite real data existing in entity_records.

Root cause

The stats query filtered and grouped on data->>'domain', but neither entity type stores the domain name under that key:

Entity type Actual field
SubdomainRequest root_domain
DnsRecord zone_name

Because no rows matched data->>'domain' = ANY(...), every aggregate came back 0.

Fix

  • WHERE clause now matches each entity type against its own field (root_domain / zone_name)
  • SELECT and GROUP BY use COALESCE(data->>'root_domain', data->>'zone_name') as the per-domain key

Verified against production

For is-not-a.dev the corrected query returns:

  • 111 approved subdomains
  • 3 pending requests
  • 165 managed DNS records

(Previously all 0.)

Checks

  • 283 / 283 tests pass
  • ESLint clean

SubdomainRequest stores the domain in 'root_domain', DnsRecord uses
'zone_name'. The previous query filtered on data->>'domain' which
matches neither, so all counts (active subdomains, pending requests,
new 7d, managed DNS records) returned 0 for every domain.

Fix:
- WHERE clause now matches each entity type against its own field
- GROUP BY / SELECT use COALESCE(root_domain, zone_name) as the key
- Verified against production data: is-not-a.dev returns 111 approved,
  3 pending, 165 managed DNS records (vs 0 for all before this fix)
@andrewstech
andrewstech merged commit b42eb92 into main Oct 23, 2026
2 checks passed
@andrewstech
andrewstech deleted the fix/domain-provider-stats-wrong-domain-field branch October 23, 2026 14:34
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