diff --git a/asset_list/app.py b/asset_list/app.py index df2fe9cc..5bbf25d4 100644 --- a/asset_list/app.py +++ b/asset_list/app.py @@ -21,9 +21,13 @@ EPC_AUTH_TOKEN = os.getenv("EPC_AUTH_TOKEN") def get_data( - df, fulladdress_column, address1_column, postcode_column, manual_uprn_map, - uprn_column=None, epc_api_only=False, row_id_name="row_id" + df, manual_uprn_map, epc_api_only=False, row_id_name="row_id" ): + uprn_column = AssetList.STANDARD_UPRN + fulladdress_column = AssetList.STANDARD_FULL_ADDRESS + address1_column = AssetList.STANDARD_ADDRESS_1 + postcode_column = AssetList.STANDARD_POSTCODE + # These re-map the standard property types to forms accepted by the EPC api, so we can predict EPCs property_type_map = { "house": "House", @@ -57,14 +61,14 @@ def get_data( postcode=postcode, auth_token=EPC_AUTH_TOKEN, os_api_key="", - property_type=property_type, + property_type=None, fast=True, full_address=full_address, max_retries=5, uprn=uprn ) # Force the skipping of estimating the EPC - searcher.ordnance_survey_client.property_type = property_type + searcher.ordnance_survey_client.property_type = None searcher.ordnance_survey_client.built_form = None searcher.find_property(skip_os=True) @@ -102,6 +106,11 @@ def get_data( searcher.find_property(skip_os=True) + # As a final resort, we estimate the EPC + if property_type is not None: + searcher.ordnance_survey_client.property_type = property_type + searcher.find_property(skip_os=True) + if searcher.newest_epc is None: no_epc.append(home[row_id_name]) continue @@ -328,12 +337,7 @@ def app(): chunk = asset_list.standardised_asset_list[i:i + chunk_size] epc_data_chunk, errors_chunk, no_epc_chunk = get_data( df=chunk, - row_id_name=asset_list.DOMNA_PROPERTY_ID, - fulladdress_column=asset_list.STANDARD_FULL_ADDRESS, - address1_column=asset_list.STANDARD_ADDRESS_1, - postcode_column=asset_list.STANDARD_POSTCODE, manual_uprn_map=MANUAL_UPRN_MAP, - uprn_column=asset_list.STANDARD_UPRN ) # We now retrieve any failed properties diff --git a/backend/SearchEpc.py b/backend/SearchEpc.py index 79a041ec..0d921bec 100644 --- a/backend/SearchEpc.py +++ b/backend/SearchEpc.py @@ -337,7 +337,7 @@ class SearchEpc: if row["lmk-key"] not in seen and not seen.add(row["lmk-key"]) ] - if data: + if data["rows"]: api_response["msg"] = self.SUCCESS return api_response["msg"]