Abri deal abandonment requires at least three parseable attempts 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-03 10:10:03 +00:00
parent af85e0ed2b
commit 88093eb7cd
2 changed files with 15 additions and 2 deletions

View file

@ -2,7 +2,7 @@ from typing import Dict, List, Optional
from backend.app.db.models.hubspot_deal_data import HubspotDealData
from etl.hubspot.project_data import ProjectData
from etl.hubspot.utils import parse_hs_bool, parse_hs_date
from etl.hubspot.utils import parse_hs_bool, parse_hs_date, parse_hs_int
class HubspotDealDiffer:
@ -226,7 +226,11 @@ class HubspotDealDiffer:
new_project: Optional[ProjectData],
old_deal: HubspotDealData,
) -> bool:
return HubspotDealDiffer._is_abri_condition_deal(new_deal, new_project)
if not HubspotDealDiffer._is_abri_condition_deal(new_deal, new_project):
return False
new_attempts = parse_hs_int(new_deal.get("number_of_attempts"))
return new_attempts is not None and new_attempts >= 3
@staticmethod
def check_for_magicplan_trigger(

View file

@ -16,6 +16,15 @@ def parse_hs_date(value: Optional[str]) -> Optional[datetime]:
return None
def parse_hs_int(value: Optional[str]) -> Optional[int]:
if not value:
return None
try:
return int(value)
except ValueError:
return None
def parse_hs_bool(value: Optional[str]) -> Optional[bool]:
if value is None or value == "":
return None