Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -148,7 +148,7 @@ async def handle_search(
|
|
| 148 |
if url_data.get('found') and url_data.get('price') is not None:
|
| 149 |
target_item = url_data['product_name']
|
| 150 |
if not requested_size: requested_size = extract_universal_sizing(url_data.get('size'))
|
| 151 |
-
|
| 152 |
original_site_deal = {
|
| 153 |
"title": target_item,
|
| 154 |
"url": input_url,
|
|
@@ -246,31 +246,19 @@ async def handle_search(
|
|
| 246 |
except Exception as redis_err:
|
| 247 |
print(f"⚠️ [Redis Error] Failed reading baseline matrix: {redis_err}")
|
| 248 |
|
| 249 |
-
# Heuristic 3: Intelligent Badge Evaluation Sequence
|
| 250 |
-
is_new_low = False
|
| 251 |
if historical_low is not None:
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
if redis_client:
|
| 256 |
-
try: redis_client.set(redis_history_key, str(cur_p))
|
| 257 |
-
except: pass
|
| 258 |
else:
|
| 259 |
-
# First time seeing this product listing, set baseline silently
|
| 260 |
if redis_client:
|
| 261 |
try: redis_client.set(redis_history_key, str(cur_p))
|
| 262 |
except: pass
|
| 263 |
-
# Only flag a new low on first crawl if it features a high-tier baseline market drop
|
| 264 |
-
if market_pct >= 30:
|
| 265 |
-
is_new_low = True
|
| 266 |
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
item['
|
| 270 |
-
else:
|
| 271 |
-
item['historical_low_event'] = False
|
| 272 |
-
if historical_low:
|
| 273 |
-
item['all_time_low_price'] = historical_low
|
| 274 |
|
| 275 |
# Map uniform parameters directly to product card context parameters
|
| 276 |
item['discount_percent'] = badge_string
|
|
|
|
| 148 |
if url_data.get('found') and url_data.get('price') is not None:
|
| 149 |
target_item = url_data['product_name']
|
| 150 |
if not requested_size: requested_size = extract_universal_sizing(url_data.get('size'))
|
| 151 |
+
|
| 152 |
original_site_deal = {
|
| 153 |
"title": target_item,
|
| 154 |
"url": input_url,
|
|
|
|
| 246 |
except Exception as redis_err:
|
| 247 |
print(f"⚠️ [Redis Error] Failed reading baseline matrix: {redis_err}")
|
| 248 |
|
| 249 |
+
# Heuristic 3: Intelligent Badge Evaluation Sequence (Historical Low Override Disabled)
|
|
|
|
| 250 |
if historical_low is not None:
|
| 251 |
+
if cur_p < historical_low and redis_client:
|
| 252 |
+
try: redis_client.set(redis_history_key, str(cur_p))
|
| 253 |
+
except: pass
|
|
|
|
|
|
|
|
|
|
| 254 |
else:
|
|
|
|
| 255 |
if redis_client:
|
| 256 |
try: redis_client.set(redis_history_key, str(cur_p))
|
| 257 |
except: pass
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
+
item['historical_low_event'] = False
|
| 260 |
+
if historical_low:
|
| 261 |
+
item['all_time_low_price'] = historical_low
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
# Map uniform parameters directly to product card context parameters
|
| 264 |
item['discount_percent'] = badge_string
|