mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
adding methodology to estimate the EPC if we don't have it
This commit is contained in:
parent
759e81f660
commit
33558957df
2 changed files with 14 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue