fix: prescreen returns immediately after HTTP check, DeepSeek runs in background

Previously /api/prescreen/batch blocked for 4-10 minutes waiting for Replicate/
DeepSeek, causing browser connection timeout and zero results saved.

- Phase 1 (HTTP check) runs synchronously and saves results immediately
- Phase 2 (DeepSeek classify) fires as asyncio.create_task and runs in background
- Response is returned to client as soon as phase 1 completes (~30-90s)
- Frontend toast shows "classifying N in background" so user knows niche/type
  will appear shortly without waiting
- Each DeepSeek sub-batch saves independently so partial results are preserved

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 08:28:26 +02:00
parent 7ec0304dea
commit daccb99a0c
2 changed files with 26 additions and 15 deletions

View File

@@ -559,7 +559,7 @@ function app() {
try {
const chunks = [];
for (let i=0; i<this.selected.length; i+=200) chunks.push(this.selected.slice(i,i+200));
let totals = {live:0,dead:0,parked:0,redirect:0,classified:0};
let totals = {live:0,dead:0,parked:0,redirect:0,error:0,classifying:0};
for (const chunk of chunks) {
const d = await fetch('/api/prescreen/batch', {
method:'POST', headers:{'Content-Type':'application/json'},
@@ -567,9 +567,10 @@ function app() {
}).then(r=>r.json());
totals.live += d.live||0; totals.dead += d.dead||0;
totals.parked += d.parked||0; totals.redirect += d.redirect||0;
totals.classified += d.classified||0;
totals.error += d.error||0; totals.classifying += d.classifying||0;
}
this.notify(`${totals.live} live · ☠ ${totals.dead} dead · 🅿 ${totals.parked} parked · 🏷 ${totals.classified} classified`, 'success');
const cls = totals.classifying > 0 ? ` · 🏷 classifying ${totals.classifying} in background` : '';
this.notify(`${totals.live} live · ☠ ${totals.dead} dead · 🅿 ${totals.parked} parked${cls}`, 'success');
this.selected = [];
await this.loadDomains();
} catch(e) { this.notify('Pre-screen failed: '+e.message, 'error'); }