From 58ce855e0b7e1800e91c0c48b2a698ac69a101dd Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Fri, 3 Jul 2026 10:13:58 +0000 Subject: [PATCH] =?UTF-8?q?Abri=20deal=20abandonment=20fires=20only=20when?= =?UTF-8?q?=20the=20deal=20newly=20becomes=20abandoned=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- etl/hubspot/hubspot_deal_differ.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/etl/hubspot/hubspot_deal_differ.py b/etl/hubspot/hubspot_deal_differ.py index 96a771a12..67f840a9e 100644 --- a/etl/hubspot/hubspot_deal_differ.py +++ b/etl/hubspot/hubspot_deal_differ.py @@ -236,12 +236,14 @@ class HubspotDealDiffer: if not HubspotDealDiffer._is_abri_condition_deal(new_deal, new_project): return False - new_attempts = parse_hs_int(new_deal.get("number_of_attempts")) - if new_attempts is None or new_attempts < 3: + if HubspotDealDiffer._is_abandoned( + old_deal.number_of_attempts, old_deal.outcome + ): return False - new_outcome = (new_deal.get("outcome") or "").lower() - return new_outcome in HubspotDealDiffer.NEGATIVE_OUTCOMES + return HubspotDealDiffer._is_abandoned( + new_deal.get("number_of_attempts"), new_deal.get("outcome") + ) @staticmethod def check_for_magicplan_trigger( @@ -251,6 +253,16 @@ class HubspotDealDiffer: old_outcome = (old_deal.outcome or "").lower() return new_outcome == "surveyed" and old_outcome != "surveyed" + @staticmethod + def _is_abandoned( + number_of_attempts: Optional[str], outcome: Optional[str] + ) -> bool: + attempts = parse_hs_int(number_of_attempts) + if attempts is None or attempts < 3: + return False + + return (outcome or "").lower() in HubspotDealDiffer.NEGATIVE_OUTCOMES + @staticmethod def _is_abri_condition_deal( new_deal: Dict[str, str], new_project: Optional[ProjectData]