sammy786 commited on
Commit
aaec41e
·
1 Parent(s): c13c413

offers: curated 114; squash evidence whitespace at display

Browse files
app/offers.py CHANGED
@@ -220,6 +220,22 @@ def is_card_linked(off: Dict) -> bool:
220
  return bool(off.get("card_id") or (off.get("applies_to_issuer") or "").strip())
221
 
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  def best_open_offer(offs: List[Dict], amount: float, category: Optional[str] = None,
224
  channel: Optional[str] = None):
225
  """Best discount available to ANYONE on this purchase, regardless of card.
@@ -239,7 +255,7 @@ def best_open_offer(offs: List[Dict], amount: float, category: Optional[str] = N
239
  continue
240
  val = offer_value(off, amount, category)
241
  if val > best:
242
- best, note = val, off.get("text") or off.get("evidence") or None
243
  return best, note
244
 
245
 
 
220
  return bool(off.get("card_id") or (off.get("applies_to_issuer") or "").strip())
221
 
222
 
223
+ def _display(s: Optional[str]) -> Optional[str]:
224
+ """A stored quote, made fit to show a person.
225
+
226
+ The evidence we bank is deliberately NOT whitespace-normalised: line breaks
227
+ are load-bearing for evidence_on_page(), which checks the quote part by part
228
+ so an offer whose headline and expiry sit on different lines still verifies.
229
+ 27 of the 114 catalogue rows carry runs of newlines for that reason, and no
230
+ row has a `text` field, so this string IS what reaches the user - it rendered
231
+ as an offer note followed by seven blank lines.
232
+
233
+ So squash at the display boundary and leave the stored quote alone.
234
+ """
235
+ s = re.sub(r"\s+", " ", s or "").strip()
236
+ return s or None
237
+
238
+
239
  def best_open_offer(offs: List[Dict], amount: float, category: Optional[str] = None,
240
  channel: Optional[str] = None):
241
  """Best discount available to ANYONE on this purchase, regardless of card.
 
255
  continue
256
  val = offer_value(off, amount, category)
257
  if val > best:
258
+ best, note = val, _display(off.get("text") or off.get("evidence"))
259
  return best, note
260
 
261
 
app/offers_data/curated_offers.json CHANGED
The diff for this file is too large to render. See raw diff