Franko Fišter commited on
Commit
56cdc39
·
1 Parent(s): f40eb86

Small fixes

Browse files
Files changed (3) hide show
  1. api/main.py +1 -1
  2. api/product_routes.py +1 -1
  3. db/scrape_repository.py +2 -13
api/main.py CHANGED
@@ -6,7 +6,7 @@ from api.receipt_routes import router as receipt_router
6
  from api.scrape_routes import router as scrape_router
7
 
8
  # Initialize FastAPI
9
- app = FastAPI(title="Product and Receipt API")
10
 
11
  # CORS configuration
12
  app.add_middleware(
 
6
  from api.scrape_routes import router as scrape_router
7
 
8
  # Initialize FastAPI
9
+ app = FastAPI(title="SupaKuna API")
10
 
11
  # CORS configuration
12
  app.add_middleware(
api/product_routes.py CHANGED
@@ -11,7 +11,7 @@ detector = ObjectDetector(
11
  input_size=INPUT_SIZE
12
  )
13
 
14
- router = APIRouter(tags=["Product Detection"])
15
 
16
 
17
  @router.options("/detect-product")
 
11
  input_size=INPUT_SIZE
12
  )
13
 
14
+ router = APIRouter(prefix="/products", tags=["Product Processing"])
15
 
16
 
17
  @router.options("/detect-product")
db/scrape_repository.py CHANGED
@@ -334,13 +334,7 @@ class PromoProductRepository:
334
  successful_stores = 0
335
  total_stores = len(stores_in_chain)
336
 
337
- # Special handling for Konzum (longer delays)
338
- is_konzum = "konzum" in matched_chain["name"].lower()
339
- store_delay = 2.0 if is_konzum else 0.5
340
-
341
  print(f"📊 Processing {total_stores} stores for {matched_chain['name']}")
342
- if is_konzum:
343
- print(f"⚠️ Konzum detected - using enhanced timeout handling")
344
 
345
  # Process each store individually with delays
346
  for i, store in enumerate(stores_in_chain):
@@ -359,17 +353,12 @@ class PromoProductRepository:
359
  print(f" ✅ Store {i+1}/{total_stores} completed successfully")
360
  else:
361
  print(f" ❌ Store {i+1}/{total_stores} failed")
362
-
363
- # Add delay between stores (longer for Konzum)
364
- if i < total_stores - 1: # Don't sleep after the last store
365
- print(f" ⏳ Waiting {store_delay}s before next store...")
366
- time.sleep(store_delay)
367
 
368
  success_rate = successful_stores / total_stores if total_stores > 0 else 0
369
  print(f"✅ Completed price processing: {successful_stores}/{total_stores} stores ({success_rate:.1%})")
370
 
371
- # Consider it successful if at least 70% of stores were updated (lower threshold for Konzum)
372
- threshold = 0.7 if is_konzum else 0.8
373
  return success_rate >= threshold
374
 
375
  except Exception as e:
 
334
  successful_stores = 0
335
  total_stores = len(stores_in_chain)
336
 
 
 
 
 
337
  print(f"📊 Processing {total_stores} stores for {matched_chain['name']}")
 
 
338
 
339
  # Process each store individually with delays
340
  for i, store in enumerate(stores_in_chain):
 
353
  print(f" ✅ Store {i+1}/{total_stores} completed successfully")
354
  else:
355
  print(f" ❌ Store {i+1}/{total_stores} failed")
 
 
 
 
 
356
 
357
  success_rate = successful_stores / total_stores if total_stores > 0 else 0
358
  print(f"✅ Completed price processing: {successful_stores}/{total_stores} stores ({success_rate:.1%})")
359
 
360
+ # Consider it successful if at least 80% of stores were updated
361
+ threshold = 0.8
362
  return success_rate >= threshold
363
 
364
  except Exception as e: