differ handles missing timezone from hubspot 🟩

This commit is contained in:
Daniel Roth 2026-04-09 16:40:47 +00:00
parent 3123723e8b
commit 9852aa2809
3 changed files with 14 additions and 6 deletions

View file

@ -103,6 +103,10 @@ class HubspotDealDiffer:
if old_value != new_value:
return True
# --- Time field ---
if old_deal.confirmed_survey_time != new_deal.get("confirmed_survey_time"):
return True
# No differences found
return False

View file

@ -362,14 +362,13 @@ def test_db_update_trigger__missing_hubspot_timezone__returns_false() -> None:
new_deal = make_new_deal(
deal_id,
design_completion_date=datetime(2025, 11, 3, 0, 0),
hs_object_id="1",
design_completion_date=datetime(2025, 11, 3, 0, 0).isoformat(),
)
new_company = "new_company"
result = HubspotDealDiffer.check_for_db_update_trigger(
new_deal=new_deal,
new_company=new_company,
new_company=None,
new_listing=None,
old_deal=old_deal,
)

View file

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from typing import Optional
@ -6,6 +6,11 @@ def parse_hs_date(value: Optional[str]) -> Optional[datetime]:
if not value:
return None
try:
return datetime.fromisoformat(value.replace("Z", "+00:00"))
dt = datetime.fromisoformat(value.replace("Z", "+00:00"))
if dt.tzinfo is None:
return dt.replace(tzinfo=timezone.utc)
return dt.astimezone(timezone.utc)
except ValueError:
return None