diff --git a/.idea/Model.iml b/.idea/Model.iml index 4413bb06..b0f9c00d 100644 --- a/.idea/Model.iml +++ b/.idea/Model.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 6f308057..1122b380 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 70827de2..33759010 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -638,7 +638,7 @@ async def build_mds(body: PlanTriggerRequest): ) input_properties = [] - for property_id, config in tqdm(enumerate(plan_input)): + for property_id, config in tqdm(enumerate(plan_input), total=len(plan_input)): # We validate each record in the file. If the record is NOT valid, we need to handle this accordingly uprn = config.get("uprn", None) if uprn: diff --git a/etl/customers/eon/pilot_asset_list.py b/etl/customers/eon/pilot_asset_list.py index 8401fde5..f46ed21b 100644 --- a/etl/customers/eon/pilot_asset_list.py +++ b/etl/customers/eon/pilot_asset_list.py @@ -114,6 +114,33 @@ def extract_mds_measures(config): return measures +def parse_property_type(config): + # This should come from the ordnance survey api eventually + + # array(['Detached', 'Semi-detached', 'Bungalow', 'Mid Terrace', + # 'End Terrace', 'Top Flat', 'Mid Flat', + # 'Low rise flat (1-2 storey)', nan], dtype=object) + + if config["Address"] == "Flat Central Garage": + return {"property_type": "Bungalow", "built_form": "Mid-Terrace"} + + if pd.isnull(config["Property Type"]): + return {"property_type": None, "built_form": None} + + lookup = { + "Detached": {"property_type": "House", "built_form": "Detached"}, + "Semi-detached": {"property_type": "House", "built_form": "Semi-detached"}, + "Bungalow": {"property_type": "Bungalow", "built_form": "Detached"}, + "Mid Terrace": {"property_type": "House", "built_form": "Mid Terrace"}, + "End Terrace": {"property_type": "House", "built_form": "End Terrace"}, + "Top Flat": {"property_type": "Flat", "built_form": None}, + "Mid Flat": {"property_type": "Flat", "built_form": None}, + "Low rise flat (1-2 storey)": {"property_type": "Flat", "built_form": None}, + } + + return lookup[config["Property Type"]] + + def app(): """ Create the initial asset list for the E.ON pilot @@ -174,6 +201,8 @@ def app(): # import pandas as pd # asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn) # asset_list_with_uprn_df.to_csv("eon_asset_list_with_uprn.csv", index=False) + # Read in + # asset_list_with_uprn = pd.read_csv("eon_asset_list_with_uprn.csv").to_dict(orient="records") # Store the asset list and create the portfolio payload asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn) @@ -191,13 +220,17 @@ def app(): measures = extract_mds_measures(config) + # Get the property type + pt = parse_property_type(config) + finalised_asset_list.append( { "address": config["Address"], "postcode": config["Postcode"], "uprn": asset_config["uprn"].values[0], "n_bedrooms": config["No Bedrooms"], - "measures": measures + "measures": measures, + **pt } ) finalised_asset_list = pd.DataFrame(finalised_asset_list)