From 28b4a8927f600e644d221d1abc4ac3a753dac89a Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Tue, 7 Jul 2026 10:13:48 +0000 Subject: [PATCH] =?UTF-8?q?A=20scrape=20that=20fires=20Abri=20triggers=20b?= =?UTF-8?q?uilds=20one=20message=20naming=20the=20fired=20flows=20?= =?UTF-8?q?=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/abri_flow_triggers.py | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/etl/hubspot/abri_flow_triggers.py b/etl/hubspot/abri_flow_triggers.py index a379acd6f..6d72bbfcc 100644 --- a/etl/hubspot/abri_flow_triggers.py +++ b/etl/hubspot/abri_flow_triggers.py @@ -26,4 +26,34 @@ def build_abri_trigger_message( old_deal: HubspotDealData, ) -> Optional[Dict[str, Any]]: """The Abri trigger message for this scrape, or None if no flow fired.""" - raise NotImplementedError + flows: List[str] = [] + if HubspotDealDiffer.check_for_abri_job_amendment( + new_deal=new_deal, new_project=new_project, old_deal=old_deal + ): + flows.append("amend_job") + if HubspotDealDiffer.check_for_abri_job_logging( + new_deal=new_deal, new_project=new_project, old_deal=old_deal + ): + flows.append("log_job") + if HubspotDealDiffer.check_for_abri_tenant_data_fetch( + new_deal=new_deal, new_project=new_project, old_deal=old_deal + ): + flows.append("sync_tenant_data") + + if not flows: + return None + + confirmed_survey_date = parse_hs_date(new_deal.get("confirmed_survey_date")) + listing = new_listing or {} + return { + "hubspot_deal_id": hubspot_deal_id, + "flows": flows, + "place_ref": listing.get("owner_property_id"), + "deal_name": new_deal.get("dealname"), + "confirmed_survey_date": ( + confirmed_survey_date.date().isoformat() + if confirmed_survey_date is not None + else None + ), + "confirmed_survey_time": new_deal.get("confirmed_survey_time"), + }