From 5d6f4b3aead6f46a1c3ea21ab41fe0c9f4509e01 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 31 Mar 2026 10:41:03 +0000 Subject: [PATCH] added checks --- etl/hubspot/hubspotDataTodB.py | 8 ++++---- etl/hubspot/scripts/scraper/main.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etl/hubspot/hubspotDataTodB.py b/etl/hubspot/hubspotDataTodB.py index 58da4036..f7f79e46 100644 --- a/etl/hubspot/hubspotDataTodB.py +++ b/etl/hubspot/hubspotDataTodB.py @@ -63,7 +63,7 @@ class HubspotDataToDb: def new_record_to_hubspot_data(self, deal_data, company, listing, hubspot_client): print("⚠️ Deprecated — use the new interface instead.") - return self.upsert_hubspot_deal(deal_data, company, listing, hubspot_client) + return self.upsert_deal(deal_data, company, listing, hubspot_client) def find_all_deals_with_company_id(self, company_id): """Returns a list of deals for a given company_id.""" @@ -90,7 +90,7 @@ class HubspotDataToDb: sha256.update(chunk) return sha256.hexdigest() - def update_deal(self, deal_in_db, hubspot_client) -> bool: + def update_deal_with_checks(self, deal_in_db, hubspot_client) -> bool: """ Checks if a deal needs updating and syncs it with HubSpot. Also handles major_condition_issue_photos file upload to S3 with integrity check. @@ -164,7 +164,7 @@ class HubspotDataToDb: print( f"❗ Discrepancies found for deal_id {deal_in_db.deal_id} — syncing with HubSpot." ) - self.upsert_hubspot_deal(hs_deal, hs_company_id, hs_listing, hubspot_client) + self.upsert_deal(hs_deal, hs_company_id, hs_listing, hubspot_client) return False # Handle photo upload if it exists but S3 URL is missing @@ -219,7 +219,7 @@ class HubspotDataToDb: return True - def upsert_hubspot_deal(self, deal_data, company, listing, hubspot_client): + def upsert_deal(self, deal_data, company, listing, hubspot_client): """ Inserts or updates a deal record. Also uploads photos if present and adds S3 URL. diff --git a/etl/hubspot/scripts/scraper/main.py b/etl/hubspot/scripts/scraper/main.py index 94342497..48864b22 100644 --- a/etl/hubspot/scripts/scraper/main.py +++ b/etl/hubspot/scripts/scraper/main.py @@ -32,9 +32,9 @@ def handler(body: dict[str, Any], context: Any, local: bool = False) -> None: deal = dbloader.find_deal_with_deal_id(hubspot_deal_id) if deal: - dbloader.update_deal(deal, hubspot) + dbloader.update_deal_with_checks(deal, hubspot) else: deal, company, listing = hubspot.get_deal_info_for_db(hubspot_deal_id) - dbloader.upsert_hubspot_deal(deal, company, listing, hubspot) + dbloader.upsert_deal(deal, company, listing, hubspot) print("Finsihed running")