fix(scraper): pathModel -x-c{id} suffix + defensive int cast

Ne yaptık:
- queue_worker.py find_leaves: kategori URL'sine -x-c{id} suffix ekledik
  (ör: makyaj-cantasi -> makyaj-cantasi-x-c1110)
- scraper.py fetch_all_products: total degeri str gelirse int'e cast
  ediyoruz (roughTotal "0" string donuyordu, '/' operatoru patliyordu)

Neden yaptık:
- Trendyol Search API path formati degisti, artik suffix'siz cagri 0
  urun donduruyor (ornek test: makyaj-cantasi=0, makyaj-cantasi-x-c1110=15.712)
- Yan etki olarak 'total' int 0 falsy oldugu icin 'or' chain
  roughTotal'a dusuyor, bu da string olarak donuyor ve math.ceil(str/int)
  TypeError firlatiyordu. Tum 35 alt kategori bu yuzden patladi
  (rapor 62 "Makyaj Analizi" sifir urun).
- Fix iki seviyeli: asil cozum suffix (artik dogru data ceker), defansif
  int() cast gelecekte API'nin baska sekilde tutarsiz donmesine karsi
  guvenlik agi.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
furkanyigit34
2026-04-25 16:38:13 +03:00
parent d9a6dda190
commit 706f957ba2
2 changed files with 8 additions and 2 deletions

View File

@@ -210,7 +210,11 @@ class TrendyolSearchScraper:
if not first:
return []
total = first.get("total", 0) or first.get("totalCount", 0) or first.get("roughTotal", 0)
total_raw = first.get("total") or first.get("totalCount") or first.get("roughTotal") or 0
try:
total = int(total_raw)
except (ValueError, TypeError):
total = 0
raw_products = first.get("products", [])
if total == 0 and not raw_products: