Model/etl/hubspot/scripts/scraper/main.py
2026-04-08 10:55:48 +00:00

24 lines
896 B
Python

from etl.hubspot.hubspotClient import HubspotClient
from etl.hubspot.hubspotDataTodB import HubspotDataToDb
from backend.utils.subtasks import task_handler
from typing import Any
@task_handler()
def handler(body: dict[str, Any], context: Any) -> None:
hubspot_deal_id = body.get("hubspot_deal_id", "")
if hubspot_deal_id == "":
raise RuntimeError(
"Missing Hubspot Deal ID in SQS body request, 'hubspot_deal_id'"
)
hubspot_deal_id = "327170793707"
hubspot: HubspotClient = HubspotClient()
dbloader: HubspotDataToDb = HubspotDataToDb()
db_deal = dbloader.find_deal_with_deal_id(hubspot_deal_id)
if db_deal:
dbloader.update_deal_with_checks(db_deal, hubspot)
else:
hubspot_deal, company, listing = hubspot.get_deal_info_for_db(hubspot_deal_id)
dbloader.upsert_deal(hubspot_deal, company, listing, hubspot)