mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
The scraper sends fired Abri flows to the abri queue on each deal change 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
28b4a8927f
commit
d70853bfd2
2 changed files with 24 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue