fix: 'Not checked' routes to DuckDB, not SQLite

prescreen_status='none' was truthy so it triggered /api/enriched, which only
finds rows already in enriched_domains with NULL status — missing all the
unprocessed domains that only exist in the 72M DuckDB index.

- exclude 'none' from the hasEnrichFilter check
- 'Not checked' now uses /api/domains (DuckDB) and filters client-side:
  rows where prescreen_status is absent = never touched
- all other prescreen status values (live/dead/parked/error) still use
  /api/enriched server-side

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 09:10:48 +02:00
parent 2f0959b8e8
commit 19eeaf1588

View File

@@ -493,23 +493,29 @@ function app() {
if (this.f.alpha_only) p.set('alpha_only', 'true'); if (this.f.alpha_only) p.set('alpha_only', 'true');
if (this.f.no_sld) p.set('no_sld', 'true'); if (this.f.no_sld) p.set('no_sld', 'true');
const hasEnrichFilter = this.f.prescreen_status || this.f.niche || this.f.site_type || this.f.country; // 'none' (Not checked) = domains never in the pipeline → must search DuckDB.
// Any other enrichment filter (live/dead/parked, niche, site_type, country)
// requires the SQLite enriched_domains table.
const hasEnrichFilter = (this.f.prescreen_status && this.f.prescreen_status !== 'none')
|| this.f.niche || this.f.site_type || this.f.country;
let endpoint; let endpoint;
if (hasEnrichFilter) { if (hasEnrichFilter) {
// Enrichment filters require the SQLite table — add them server-side
if (this.f.prescreen_status) p.set('prescreen_status', this.f.prescreen_status); if (this.f.prescreen_status) p.set('prescreen_status', this.f.prescreen_status);
if (this.f.niche) p.set('niche', this.f.niche); if (this.f.niche) p.set('niche', this.f.niche);
if (this.f.site_type) p.set('site_type', this.f.site_type); if (this.f.site_type) p.set('site_type', this.f.site_type);
if (this.f.country) p.set('country', this.f.country.trim().toUpperCase()); if (this.f.country) p.set('country', this.f.country.trim().toUpperCase());
endpoint = '/api/enriched'; endpoint = '/api/enriched';
} else { } else {
// Discovery mode: search full 72M DuckDB index (e.g. "Not checked" keyword search)
endpoint = '/api/domains'; endpoint = '/api/domains';
} }
const d = await fetch(endpoint + '?' + p).then(r=>r.json()); const d = await fetch(endpoint + '?' + p).then(r=>r.json());
this.domainsTotal = d.total || 0; this.domainsTotal = d.total || 0;
this.domains = d.results || []; let rows = d.results || [];
// 'Not checked': DuckDB returns all domains joined with enriched data;
// filter client-side to keep only those with no prescreen_status yet.
if (this.f.prescreen_status === 'none') rows = rows.filter(r => !r.prescreen_status);
this.domains = rows;
} catch(e) { this.notify('Failed to load: '+e.message, 'error'); } } catch(e) { this.notify('Failed to load: '+e.message, 'error'); }
finally { this.loading = false; } finally { this.loading = false; }
}, },