handling error cases in storing data to db for estimated properties

This commit is contained in:
Khalim Conn-Kowlessar 2024-01-04 11:27:19 +00:00
parent 41749e8557
commit 1eb6f4c2a7
2 changed files with 3 additions and 1 deletions

View file

@ -459,7 +459,7 @@ class Property(Definitions):
"""
Utility function for usage in the lambda, for preparing the _rating fields
"""
return rating_lookup[field].value if field not in cls.DATA_ANOMALY_MATCHES else None
return rating_lookup[field].value if (field not in cls.DATA_ANOMALY_MATCHES) and (field is not None) else None
def get_property_details_epc(self, portfolio_id: int, rating_lookup):

View file

@ -591,6 +591,7 @@ class SearchEpc:
estimated_epc["postcode"] = self.postcode
estimated_epc["uprn"] = self.uprn
estimated_epc["address"] = self.full_address
# Indicate that this epc was estimated
estimated_epc["estimated"] = True
@ -676,6 +677,7 @@ class SearchEpc:
return
# Step 4: If we still don't have an EPC, we estimate the EPC data
self.full_address = self.ordnance_survey_client.most_relevant_result["ADDRESS"]
estimated_epc = self.estimate_epc(
property_type=self.ordnance_survey_client.property_type,
built_form=self.ordnance_survey_client.built_form