import sqlite3
p='/opt/struktur/content-extraction/data/content_extraction.db'; c=sqlite3.connect(p)
first=('kundenprojekte-business-2026-09-08','customer_projects','Business','newest',10,'legacy: ursprünglich Importzeit; nachträglich dokumentiert','Verkaufbare KI-/Automatisierungsleistungen für KMU identifizieren','2026-09-08T09:00:00Z','2026-09-08T09:10:00Z',10,9,1,'Fünf Ausgangsprojekte: SOP-Agent, Human-in-loop-Automation, AI-Rezeptionist, Skill-Library, Content/Landingpage.')
second=('kundenprojekte-business-2026-09-08-b02','customer_projects','Business','published_at_desc',10,'KI: max. 90 Tage; Fallback bis 120 Tage nur bei zu wenig Material','Bestehende Kundenprojekte validieren und neue verkaufbare KI-/Automatisierungsleistungen finden','2026-09-08T09:41:00Z','2026-09-08T09:50:00Z',10,10,0,'Bestehende Projekte stark bestätigt. Neuer Kandidat: KI-Wissens- & Onboarding-System. Research/Monitoring-Agent nur als Beobachtung, noch kein eigenes Projekt.')
sql='INSERT OR REPLACE INTO ce_analysis_batches(batch_id,analysis_type,search_terms,sort_mode,requested_count,recency_policy,purpose,started_at,completed_at,selected_count,usable_count,missing_count,result_summary) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)'
c.execute(sql,first); c.execute(sql,second)
ids=[953,954,963,983,928,918,872,862,812,815]
for sid in ids:
c.execute('''INSERT INTO ce_analysis_marks(source_id,analysis_type,status,batch_id,analyzed_at,output_refs,note) VALUES(?,?,?,?,?,?,?) ON CONFLICT(source_id,analysis_type) DO UPDATE SET status=excluded.status,batch_id=excluded.batch_id,analyzed_at=excluded.analyzed_at,output_refs=excluded.output_refs,note=excluded.note,updated_at=CURRENT_TIMESTAMP''',(sid,'customer_projects','processed',second[0],'2026-09-08T09:50:00Z','sop-agent-system;prozess-human-loop;ai-rezeptionist-lead-agent;skill-library-orchestration;content-landingpage-service;ki-wissens-onboarding','Business batch 02; published_at within 90 days; transcript usable'))
c.commit()
print('MARKS_B02',c.execute("select count(*) from ce_analysis_marks where batch_id=? and status='processed'",(second[0],)).fetchone()[0])
for r in c.execute('select batch_id,search_terms,selected_count,usable_count,missing_count,recency_policy from ce_analysis_batches order by batch_id'): print(r)