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

@@ -122,7 +122,9 @@ class QueueWorker:
if not children:
cat = tree_by_id.get(parent_id)
if cat:
path_model = (cat.get("url") or "").lstrip("/") or None
url_slug = (cat.get("url") or "").lstrip("/")
# Trendyol Search API now requires -x-c{id} suffix on pathModel
path_model = f"{url_slug}-x-c{cat['id']}" if url_slug else None
return [(path_model, cat["name"], cat["id"])]
return []
leaves = []