fix(scrape): 0 ürünlü rapor FAILED olarak işaretleniyor
All checks were successful
ciromarket-backend-build-and-deploy / build (push) Successful in 2m8s

Ne yaptık:
- SSE endpoint: tüm subcategory'ler başarısız olursa type=failed event yield et, DB'ye kaydetme
- queue_worker: total_products==0 ve en az 1 kategori denendiyse _mark_failed() çağır

Neden yaptık:
- Trendyol rate limit (HTTP 556) durumunda tüm subcategory'ler success=False dönüyor
- Sistem bunu hata olarak değil "0 ürünlü başarılı rapor" olarak kaydediyordu
- Kullanıcıya "Bu kategoride ürün bulunamadı / Farklı kategori deneyin" mesajı çıkıyordu — tamamen yanıltıcı
- Artık FAILED → Spring Boot CiromarketSseConsumer/QueuePoller → SellerX DB FAILED → frontend hata mesajı
This commit is contained in:
2026-07-23 00:55:25 +03:00
parent 2b0e83f2eb
commit b1cad27330
2 changed files with 13 additions and 0 deletions

View File

@@ -1865,6 +1865,13 @@ async def create_report(
await asyncio.to_thread(_write_json, json_filename, combined_data)
# Tüm subcategory'ler başarısız olduysa raporu kaydetme, FAILED döndür
successful_count = sum(1 for d in results.get("details", []) if d.get("success"))
total_attempted = len(results.get("details", []))
if total_attempted > 0 and successful_count == 0:
yield f"data: {json_module.dumps({'type': 'failed', 'reason': 'scrape_failed', 'message': 'Trendyol geçici olarak kullanılamıyor. Lütfen birkaç dakika bekleyip tekrar deneyin.', 'progress': 100})}\n\n"
return
# Save to database
yield f"data: {json_module.dumps({'type': 'info', 'message': '💾 Veritabanına kaydediliyor...', 'progress': 93})}\n\n"
await asyncio.sleep(0.5)