From d70853bfd2fc84079276828e22ea3274839091d7 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Tue, 7 Jul 2026 10:16:13 +0000 Subject: [PATCH] =?UTF-8?q?The=20scraper=20sends=20fired=20Abri=20flows=20?= =?UTF-8?q?to=20the=20abri=20queue=20on=20each=20deal=20change=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 --- backend/app/config.py | 1 + etl/hubspot/scripts/scraper/main.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/backend/app/config.py b/backend/app/config.py index 8939e6ff8..df6a32d1d 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -40,6 +40,7 @@ class Settings(BaseSettings): CATEGORISATION_SQS_URL: str = "changeme" PASHUB_TO_ARA_SQS_URL: str = "changeme" MAGICPLAN_SQS_URL: str = "changeme" + ABRI_SQS_URL: str = "changeme" POSTCODE_SPLITTER_SQS_URL: str = "changeme" COMBINER_SQS_URL: str = "changeme" LANDLORD_OVERRIDES_SQS_URL: str = "changeme" diff --git a/etl/hubspot/scripts/scraper/main.py b/etl/hubspot/scripts/scraper/main.py index 589e526b8..56ac8b9a5 100644 --- a/etl/hubspot/scripts/scraper/main.py +++ b/etl/hubspot/scripts/scraper/main.py @@ -6,6 +6,7 @@ from backend.app.config import get_settings from etl.hubspot.hubspotClient import HubspotClient from etl.hubspot.hubspotDataTodB import CompanyData, HubspotDataToDb from etl.hubspot.project_data import ProjectData +from etl.hubspot.abri_flow_triggers import build_abri_trigger_message from etl.hubspot.hubspot_deal_differ import HubspotDealDiffer from etl.hubspot.hubspot_trigger_orchestrator_trigger_request import ( HubspotTriggerOrchestratorTriggerRequest, @@ -57,6 +58,8 @@ def handler(body: dict[str, Any], context: Any) -> None: # ============================== # Orchestration of other lambdas # ============================== + # No Abri triggers here: Abri deals are always created bare and their + # dates are set later by ops, so a first scrape can never fire one. if hubspot_deal["pashub_link"]: logger.info( f"Triggering Pas Hub file fetcher for HubSpot deal ID {hubspot_deal_id}" @@ -125,6 +128,26 @@ def handler(body: dict[str, Any], context: Any) -> None: sqs_client, hubspot_deal, listing, hubspot_deal_id ) + abri_message = build_abri_trigger_message( + hubspot_deal_id=hubspot_deal_id, + new_deal=hubspot_deal, + new_project=project, + new_listing=listing, + old_deal=db_deal, + ) + if abri_message: + logger.info( + f"Triggering Abri flows {abri_message['flows']} for HubSpot " + f"deal ID {hubspot_deal_id}" + ) + response = sqs_client.send_message( + QueueUrl=get_settings().ABRI_SQS_URL, + MessageBody=json.dumps(abri_message), + ) + logger.info( + f"Sent message to Abri queue. MessageId: {response['MessageId']}" + ) + print("done")