ghstedpixel commited on
Commit
f0d10d9
·
verified ·
1 Parent(s): f0901bd

Update coupons.py

Browse files
Files changed (1) hide show
  1. coupons.py +11 -9
coupons.py CHANGED
@@ -135,15 +135,17 @@ async def fetch_active_coupons_and_deals(product_name: str, client: httpx.AsyncC
135
  desc_val = str(o.get('description', ''))
136
  source_val = str(o.get('source', ''))
137
 
138
- # Dynamic handling based on whether it's a Coupon code or a direct Store Deal
139
- if offer_type == "coupon":
140
- if not code_val or code_val in blacklisted_tokens or len(code_val) < 3:
141
- continue
142
- else: # 'deal' handling
143
- if "click" in desc_val.lower() and len(desc_val) < 15:
144
- continue # Strip lazy clickbait
145
- if code_val in blacklisted_tokens:
146
- code_val = "N/A" # Normalize missing codes on native sales
 
 
147
 
148
  if desc_val:
149
  clean_offers.append({
 
135
  desc_val = str(o.get('description', ''))
136
  source_val = str(o.get('source', ''))
137
 
138
+ # Normalize missing, broken, or placeholder codes to an empty string
139
+ if code_val in blacklisted_tokens or code_val == "N/A" or not code_val:
140
+ code_val = ""
141
+
142
+ # Dynamic re-classification safety check
143
+ if offer_type == "coupon" and not code_val:
144
+ offer_type = "deal"
145
+
146
+ # Clear out lazy clickbait affiliate phrases
147
+ if "click" in desc_val.lower() and len(desc_val) < 15:
148
+ continue
149
 
150
  if desc_val:
151
  clean_offers.append({