diff --git a/backend/address2UPRN/main.py b/backend/address2UPRN/main.py index d0ba36e6..97e2037a 100644 --- a/backend/address2UPRN/main.py +++ b/backend/address2UPRN/main.py @@ -462,6 +462,15 @@ def handler(event, context, local=False): # Validate postcode before processing if not AddressMatch.is_valid_postcode(postcode): logger.warning(f"Postcode {postcode} is invalid, skipping") + for row in postcode_rows: + results_data.append( + { + **row, + "address2uprn_uprn": "invalid postcode", + "address2uprn_address": "invalid postcode", + "address2uprn_lexiscore": "invalid postcode", + } + ) continue # Fetch EPC data once per postcode diff --git a/etl/hubspot/hubspotDataTodB.py b/etl/hubspot/hubspotDataTodB.py index ac980649..6325efc2 100644 --- a/etl/hubspot/hubspotDataTodB.py +++ b/etl/hubspot/hubspotDataTodB.py @@ -365,9 +365,11 @@ class HubspotDataToDb: for attr, value in { "dealname": deal_data.get("dealname"), "dealstage": deal_data.get("dealstage"), - "listing_id": listing.get("listing_id"), - "landlord_property_id": listing.get("owner_property_id"), - "uprn": listing.get("national_uprn"), + "listing_id": listing.get("listing_id", None) if listing else None, + "landlord_property_id": ( + listing.get("owner_property_id", None) if listing else None + ), + "uprn": listing.get("national_uprn", None) if listing else None, "outcome": deal_data.get("outcome"), "outcome_notes": deal_data.get("outcome_notes"), "project_code": deal_data.get("project_code"), @@ -385,7 +387,9 @@ class HubspotDataToDb: "pashub_link": deal_data.get("pashub_link"), "sharepoint_link": deal_data.get("sharepoint_link"), "dampmould_growth": deal_data.get("dampmould_growth"), - "damp_mould_and_repairs_comments": deal_data.get("damp_mould_and_repairs_comments"), + "damp_mould_and_repairs_comments": deal_data.get( + "damp_mould_and_repairs_comments" + ), "pre_sap": deal_data.get("pre_sap"), "coordinator": deal_data.get("coordinator"), "mtp_completion_date": self._parse_hs_date( @@ -472,9 +476,9 @@ class HubspotDataToDb: deal_id=deal_id, dealname=deal_data.get("dealname"), dealstage=deal_data.get("dealstage"), - listing_id=listing.get("listing_id", None), - landlord_property_id=listing.get("owner_property_id"), - uprn=listing.get("national_uprn"), + listing_id=listing.get("listing_id", None) if listing else None, + landlord_property_id=listing.get("owner_property_id") if listing else None, + uprn=listing.get("national_uprn") if listing else None, outcome=deal_data.get("outcome"), outcome_notes=deal_data.get("outcome_notes"), project_code=deal_data.get("project_code"), @@ -490,7 +494,9 @@ class HubspotDataToDb: pashub_link=deal_data.get("pashub_link"), sharepoint_link=deal_data.get("sharepoint_link"), dampmould_growth=deal_data.get("dampmould_growth"), - damp_mould_and_repairs_comments=deal_data.get("damp_mould_and_repairs_comments"), + damp_mould_and_repairs_comments=deal_data.get( + "damp_mould_and_repairs_comments" + ), pre_sap=deal_data.get("pre_sap"), coordinator=deal_data.get("coordinator"), mtp_completion_date=self._parse_hs_date( diff --git a/etl/hubspot/scripts/scraper/main.py b/etl/hubspot/scripts/scraper/main.py index 99311f6b..4f71c6d0 100644 --- a/etl/hubspot/scripts/scraper/main.py +++ b/etl/hubspot/scripts/scraper/main.py @@ -2,8 +2,6 @@ from etl.hubspot.hubspotClient import HubspotClient from etl.hubspot.hubspotDataTodB import HubspotDataToDb from backend.utils.subtasks import task_handler from typing import Any -import json -import time @task_handler() @@ -14,6 +12,7 @@ def handler(body: dict[str, Any], context: Any) -> None: raise RuntimeError( "Missing Hubspot Deal ID in SQS body request, 'hubspot_deal_id'" ) + hubspot_deal_id = "327170793707" hubspot: HubspotClient = HubspotClient() dbloader: HubspotDataToDb = HubspotDataToDb()