fix: search race condition + brand detection + contacts + reassess

- loadDomains(): add generation counter so stale auto-advance fetches
  cannot overwrite a newer user-triggered search result; snapshot filter
  state before the first await so URL reflects what was requested; add
  HTTP status check so backend errors surface as toasts rather than
  silent empty results; auto-advance now calls loadDomains() without
  await so the counter increments correctly per page advance

- beauty_ai: word-boundary regex for short brands (≤5 chars) to stop
  'ref' matching 'reference'/'refresh'/'prefer' etc.; merge phones,
  whatsapp and social_links from site_analyzer directly into result
  (more reliable than AI extraction); add contact_whatsapp and
  contact_social fields to AI JSON schema

- db: add requeue_beauty() for re-assessing already-assessed domains

- beauty_main: /api/beauty/reassess/batch endpoint using requeue_beauty

- index.html: Re-assess Selected bulk button, per-row ↺ button in
  Browse and Pipeline, WhatsApp + social links in Pipeline contact panel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 11:06:58 +02:00
parent be0fbb502c
commit d9ece58e12
4 changed files with 141 additions and 27 deletions

View File

@@ -540,6 +540,19 @@ async def queue_beauty(domains: list[str]):
await db.commit()
async def requeue_beauty(domains: list[str]):
"""Re-queue domains for fresh assessment even if already assessed."""
async with aiosqlite.connect(SQLITE_PATH, timeout=30) as db:
await db.executemany(
"""INSERT INTO beauty_queue (domain, status)
VALUES (?, 'pending')
ON CONFLICT(domain) DO UPDATE SET
status='pending', completed_at=NULL, error=NULL""",
[(d,) for d in domains],
)
await db.commit()
async def get_beauty_queue_status():
async with aiosqlite.connect(SQLITE_PATH, timeout=30) as db:
async with db.execute("SELECT status, COUNT(*) FROM beauty_queue GROUP BY status") as cur: