address JTK review comments

This commit is contained in:
Daniel Roth 2026-04-09 14:41:14 +00:00
parent 4425b28d4f
commit bd891a7a85
5 changed files with 9 additions and 11 deletions

View file

@ -65,8 +65,8 @@ class HubspotDealData(SQLModel, table=True):
server_default=text("(NOW() AT TIME ZONE 'utc')"),
nullable=False,
),
default=None, # Nullable in db but optional here as value is set on db save for new record
)
default=func.now(),
) # Nullable in db but optional here as value is set on db save for new record
updated_at: Optional[datetime] = Field(
sa_column=Column(
@ -75,5 +75,5 @@ class HubspotDealData(SQLModel, table=True):
onupdate=func.now(),
nullable=False,
),
default=None, # Nullable in db but optional here as value is set on db save for new record
)
default=func.now(),
) # Nullable in db but optional here as value is set on db save for new record

View file

@ -31,7 +31,7 @@ class HubspotDataToDb:
records = self.read_org_table(limit)
return [org.name for org in records if org.name]
def upsert_company(self, company_data: CompanyData) -> Organisation:
def upsert_organisation(self, company_data: CompanyData) -> Organisation:
"""Upserts a company record. Updates if hubspot_company_id exists, otherwise creates new."""
with db_read_session() as session:
hubspot_id = company_data.get("hs_object_id")

View file

@ -8,6 +8,7 @@ class HubspotDealDiffer:
COORDINATION_COMPLETE: List[str] = [
"v1 ioe/mtp complete",
"v2 ioe/mtp complete",
"v3 ioe/mtp complete",
]
RETROFIT_DESIGN_COMPLETE = "uploaded"
LODGEMENT_COMPLETE: List[str] = ["lodgement complete", "measures lodged"]
@ -72,6 +73,7 @@ class HubspotDealDiffer:
"lodgement_status": "lodgement_status",
"design_type": "design_type",
"surveyor": "surveyor",
"confirmed_survey_time": "confirmed_survey_time",
}
for hs_field, db_field in FIELD_MAP.items():
@ -101,10 +103,6 @@ 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

@ -22,7 +22,7 @@ companies_to_add_or_ensure_it_exists = [
for company in companies_to_add_or_ensure_it_exists:
company_info: CompanyData = hubspot.get_company_information(company.value)
dbRead.upsert_company(company_info)
dbRead.upsert_organisation(company_info)
dbRead = HubspotDataToDb()

View file

@ -45,7 +45,7 @@ def handler(body: dict[str, Any], context: Any) -> None:
if company:
company_data: CompanyData = hubspot_client.get_company_information(company)
db_client: HubspotDataToDb = HubspotDataToDb()
db_client.upsert_company(company_data)
db_client.upsert_organisation(company_data)
db_client.upsert_deal(hubspot_deal, company, listing, hubspot_client)
else: