allowances: fix decision-label mapping (would_renew not would_renewed)

This commit is contained in:
inference-bot committed 2026-11-04 05:17:54 +00:00
1 parent 326fec9214
commit a8bdb70e08
1 file changed
+6 -4
+6 -4
View File
@@ -4364,7 +4364,9 @@ async def reconcile_allowances(send: bool = False) -> dict:
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
contribute = credit_pack_url() contribute = credit_pack_url()
verified = "on" if (send and ALLOWANCE_POLICY == "on") else "report" verified = "on" if (send and ALLOWANCE_POLICY == "on") else "report"
label = (lambda a: a) if verified == "on" else (lambda a: "would_" + a) _APPLIED = {"renew": "renewed", "remind": "reminded", "deactivate": "deactivated"}
_WOULD = {"renew": "would_renew", "remind": "would_remind", "deactivate": "would_deactivate"}
label = (lambda a: _APPLIED[a]) if verified == "on" else (lambda a: _WOULD[a])
decisions: list[dict] = [] decisions: list[dict] = []
counts = {"renewed": 0, "reminded": 0, "deactivated": 0, counts = {"renewed": 0, "reminded": 0, "deactivated": 0,
"would_renew": 0, "would_remind": 0, "would_deactivate": 0, "in_grace": 0, "would_renew": 0, "would_remind": 0, "would_deactivate": 0, "in_grace": 0,
@@ -4416,7 +4418,7 @@ async def reconcile_allowances(send: bool = False) -> dict:
if paid: if paid:
next_reset = next_reset_for_anchor_day(anchor_day, now) next_reset = next_reset_for_anchor_day(anchor_day, now)
evidence = f"{evidence}; reset anchored to join-day {anchor_day} → next reset {next_reset.date().isoformat()}" evidence = f"{evidence}; reset anchored to join-day {anchor_day} → next reset {next_reset.date().isoformat()}"
decision = label("renewed") decision = label("renew")
counts[decision] += 1 counts[decision] += 1
if verified == "on": if verified == "on":
try: try:
@@ -4431,7 +4433,7 @@ async def reconcile_allowances(send: bool = False) -> dict:
(email, cycle_key), (email, cycle_key),
).fetchone() ).fetchone()
if not reminded: if not reminded:
decision = label("reminded") decision = label("remind")
counts[decision] += 1 counts[decision] += 1
if verified == "on": if verified == "on":
subject, text_body, html_body = payment_reminder_email(oc_slug or slug or "there", contribute) subject, text_body, html_body = payment_reminder_email(oc_slug or slug or "there", contribute)
@@ -4448,7 +4450,7 @@ async def reconcile_allowances(send: bool = False) -> dict:
sent_at = _parse_oc_dt(str(reminded[0])) sent_at = _parse_oc_dt(str(reminded[0]))
elapsed = (now - sent_at).days if sent_at else None elapsed = (now - sent_at).days if sent_at else None
if elapsed is not None and elapsed >= PAYMENT_GRACE_DAYS and ALLOWANCE_DEACTIVATE == "on": if elapsed is not None and elapsed >= PAYMENT_GRACE_DAYS and ALLOWANCE_DEACTIVATE == "on":
decision = label("deactivated") decision = label("deactivate")
counts[decision] += 1 counts[decision] += 1
evidence = f"{evidence}; reminder sent {str(reminded[0])[:10]}, grace {int(PAYMENT_GRACE_DAYS)}d elapsed" evidence = f"{evidence}; reminder sent {str(reminded[0])[:10]}, grace {int(PAYMENT_GRACE_DAYS)}d elapsed"
if verified == "on": if verified == "on":