mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
added checks
This commit is contained in:
parent
0f9d031944
commit
5d6f4b3aea
2 changed files with 6 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue