diff --git a/backend/logging_config.py b/backend/logging_config.py index e2c5acc..0b6baf5 100644 --- a/backend/logging_config.py +++ b/backend/logging_config.py @@ -121,12 +121,11 @@ def setup_logging(log_dir: str = None): - console output (INFO+, colored) """ if log_dir is None: - log_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "logs") + log_dir = "/tmp/logs" try: os.makedirs(log_dir, exist_ok=True) except PermissionError: - # Docker container'da /app/../logs yazılamayabilir, /tmp/logs kullan log_dir = "/tmp/logs" os.makedirs(log_dir, exist_ok=True) diff --git a/backend/main.py b/backend/main.py index f40fa2e..b14e504 100644 --- a/backend/main.py +++ b/backend/main.py @@ -61,6 +61,9 @@ async def verify_api_key(request: Request, api_key: Optional[str] = Security(API """ if request.url.path in PUBLIC_PATHS: return + if not API_KEY: + # API_KEY env var not set — authentication disabled + return if not api_key or api_key != API_KEY: raise HTTPException( status_code=401, diff --git a/backend/queue_worker.py b/backend/queue_worker.py index 1c0e7bc..b5851e6 100644 --- a/backend/queue_worker.py +++ b/backend/queue_worker.py @@ -168,6 +168,15 @@ class QueueWorker: scraper = TrendyolSearchScraper(path_model) products = scraper.fetch_all_products() + # Search API returned 0 — fallback to Top Rankings API + if not products and cat_id: + log.warning(f"Search API 0 ürün döndürdü ({path_model}), Top Rankings API ile fallback deneniyor...") + _trendyol_limiter.wait() + fallback_scraper = TrendyolScraper(cat_id, page_size=20) + products = fallback_scraper.fetch_all_products(delay=0.5, max_pages=5) + if products: + log.info(f"Fallback başarılı: {len(products)} ürün bulundu (cat_id={cat_id})") + # Enrich with socialProofs from Top Rankings API if products and cat_id and not any(p.get("socialProofs") for p in products): try: