mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
removing redundant code
This commit is contained in:
parent
6b46542d35
commit
d009a7adc1
1 changed files with 3 additions and 45 deletions
|
|
@ -889,7 +889,7 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
with db_read_session() as session:
|
with db_read_session() as session:
|
||||||
materials = db_funcs.materials_functions.get_materials(session)
|
materials = db_funcs.materials_functions.get_materials(session)
|
||||||
cleaned = get_cleaned()
|
cleaned = get_cleaned()
|
||||||
project_scores_matrix, partial_project_scores_matrix, whlg_eligible_postcodes = get_funding_data()
|
# project_scores_matrix, partial_project_scores_matrix, whlg_eligible_postcodes = get_funding_data()
|
||||||
|
|
||||||
kwh_client = KwhData(bucket=get_settings().DATA_BUCKET, read_consumption_data=True)
|
kwh_client = KwhData(bucket=get_settings().DATA_BUCKET, read_consumption_data=True)
|
||||||
|
|
||||||
|
|
@ -1042,6 +1042,7 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
property_instance.current_energy_bill = property_current_energy_bill
|
property_instance.current_energy_bill = property_current_energy_bill
|
||||||
|
|
||||||
# Insert the predictions into the recommendations and run the optimiser
|
# Insert the predictions into the recommendations and run the optimiser
|
||||||
|
logger.info("Optimising measures")
|
||||||
for p in input_properties:
|
for p in input_properties:
|
||||||
if not recommendations.get(p.id):
|
if not recommendations.get(p.id):
|
||||||
continue
|
continue
|
||||||
|
|
@ -1069,18 +1070,6 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
)
|
)
|
||||||
gain = optimiser_functions.calculate_gain(body=body, p=p, fixed_gain=fixed_gain, eco_packages=eco_packages)
|
gain = optimiser_functions.calculate_gain(body=body, p=p, fixed_gain=fixed_gain, eco_packages=eco_packages)
|
||||||
|
|
||||||
li_thickness = convert_thickness_to_numeric(
|
|
||||||
p.roof["insulation_thickness"], p.roof["is_pitched"], p.roof["is_flat"]
|
|
||||||
)
|
|
||||||
current_wall_u_value = p.walls["thermal_transmittance"]
|
|
||||||
if current_wall_u_value is None:
|
|
||||||
current_wall_u_value = get_wall_u_value(
|
|
||||||
clean_description=p.walls["clean_description"],
|
|
||||||
age_band=p.age_band,
|
|
||||||
is_granite_or_whinstone=p.walls["is_granite_or_whinstone"],
|
|
||||||
is_sandstone_or_limestone=p.walls["is_sandstone_or_limestone"],
|
|
||||||
)
|
|
||||||
|
|
||||||
# We insert the innovation uplift
|
# We insert the innovation uplift
|
||||||
measures_to_optimise_with_uplift = deepcopy(measures_to_optimise)
|
measures_to_optimise_with_uplift = deepcopy(measures_to_optimise)
|
||||||
|
|
||||||
|
|
@ -1217,7 +1206,7 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
)
|
)
|
||||||
|
|
||||||
property_updates, property_epc_details, property_spatial_updates = [], [], []
|
property_updates, property_epc_details, property_spatial_updates = [], [], []
|
||||||
plans_to_create, recommendations_to_create, funding_to_create = [], [], []
|
plans_to_create, recommendations_to_create = [], []
|
||||||
|
|
||||||
# Prepare the data that will need to be uploaded in bulk
|
# Prepare the data that will need to be uploaded in bulk
|
||||||
for p in input_properties:
|
for p in input_properties:
|
||||||
|
|
@ -1284,37 +1273,6 @@ async def model_engine(body: PlanTriggerRequest):
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
if recommendations_for_property and p.funded_measures:
|
|
||||||
funding_to_create.append({
|
|
||||||
"property_id": p.id,
|
|
||||||
"scheme": p.scheme,
|
|
||||||
"project_funding": float(p.project_funding),
|
|
||||||
"total_uplift": float(p.total_uplift),
|
|
||||||
"full_project_score": float(p.full_project_score),
|
|
||||||
"partial_project_score": float(p.partial_project_score),
|
|
||||||
"uplift_project_score": float(p.uplift_project_score),
|
|
||||||
"measures": [
|
|
||||||
{
|
|
||||||
"measure": (
|
|
||||||
"cavity_wall_insulation"
|
|
||||||
if part["type"] == "extension_cavity_wall_insulation"
|
|
||||||
else "sealing_fireplace"
|
|
||||||
if part["type"] == "sealing_open_fireplace"
|
|
||||||
else part["type"]
|
|
||||||
),
|
|
||||||
"material_id": (
|
|
||||||
part["parts"][0]["id"]
|
|
||||||
if part.get("parts")
|
|
||||||
else None
|
|
||||||
),
|
|
||||||
"innovation_uplift": float(part["innovation_uplift"]),
|
|
||||||
"partial_project_score": float(part["partial_project_score"]),
|
|
||||||
"uplift_project_score": float(part["uplift_project_score"]),
|
|
||||||
}
|
|
||||||
for part in p.funded_measures
|
|
||||||
],
|
|
||||||
})
|
|
||||||
|
|
||||||
# Bulk upload property data
|
# Bulk upload property data
|
||||||
logger.info("Uploading property data in bulk")
|
logger.info("Uploading property data in bulk")
|
||||||
with db_session() as session:
|
with db_session() as session:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue