mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
VE recommendations pushed to front end
This commit is contained in:
parent
54d2dce05d
commit
d4d9b8e518
5 changed files with 33 additions and 16 deletions
|
|
@ -183,6 +183,7 @@ class Property:
|
|||
# This additional condition data should change how we pass kwargs to this. We should no longer need to pass
|
||||
# kwargs to this class, but instead, we should pass the energy assessment condition data
|
||||
self.energy_assessment_condition_data = energy_assessment["condition"]
|
||||
self.energy_assessment_is_newer = energy_assessment["energy_assessment_is_newer"]
|
||||
|
||||
# TODO: We keep this but only temporarily until we add bathrooms, bedrooms, building id to the condition data
|
||||
self.parse_kwargs(kwargs)
|
||||
|
|
@ -877,7 +878,10 @@ class Property:
|
|||
property_data = {
|
||||
"creation_status": "READY",
|
||||
"uprn": int(self.data["uprn"]),
|
||||
"building_reference_number": int(self.data["building-reference-number"]),
|
||||
"building_reference_number": (
|
||||
int(self.data["building-reference-number"]) if
|
||||
self.data["building-reference-number"] is not None else None
|
||||
),
|
||||
"has_pre_condition_report": True,
|
||||
"has_recommendations": True,
|
||||
"property_type": self.data["property-type"],
|
||||
|
|
|
|||
|
|
@ -232,11 +232,12 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
"""
|
||||
|
||||
if not energy_assessment["epc"]:
|
||||
energy_assessment_is_newer = False
|
||||
return {
|
||||
'original_epc': epc_searcher.newest_epc.copy(),
|
||||
'full_sap_epc': epc_searcher.full_sap_epc.copy(),
|
||||
'old_data': epc_searcher.older_epcs.copy(),
|
||||
}
|
||||
}, energy_assessment_is_newer
|
||||
|
||||
epc = energy_assessment["epc"]
|
||||
energy_assessment_date = epc["inspection-date"].strftime("%Y-%m-%d")
|
||||
|
|
@ -249,11 +250,12 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
# We check if the energy assessment is newer than the newest EPC
|
||||
if pd.to_datetime(energy_assessment_date) > pd.to_datetime(epc_searcher.newest_epc["inspection-date"]):
|
||||
# In this case, our energy assessment is newer than the EPCs available for this property
|
||||
energy_assessment_is_newer = True
|
||||
return {
|
||||
"original_epc": epc,
|
||||
"full_sap_epc": epc_searcher.full_sap_epc.copy(),
|
||||
"old_data": epc_searcher.older_epcs.copy() + [epc_searcher.newest_epc.copy()]
|
||||
}
|
||||
}, energy_assessment_is_newer
|
||||
|
||||
# We check if the EPC we have produced is contained in the set of EPCs done for the property
|
||||
# We do this based on inspection-date and SAP
|
||||
|
|
@ -262,6 +264,7 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
if x["inspection-date"] == energy_assessment_date and
|
||||
x["current-energy-efficiency"] == epc["current-energy-efficiency"]
|
||||
]
|
||||
energy_assessment_is_newer = False
|
||||
|
||||
if epc_in_historicals:
|
||||
# Then the EPC we have produced is already in the set of EPCs, and our EPC is older than the newest
|
||||
|
|
@ -269,7 +272,7 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
"original_epc": epc_searcher.newest_epc.copy(),
|
||||
"full_sap_epc": epc_searcher.full_sap_epc.copy(),
|
||||
"old_data": epc_searcher.older_epcs.copy()
|
||||
}
|
||||
}, energy_assessment_is_newer
|
||||
|
||||
# In this case, our EPC is older than the newest publically avaible one, but is not contained in
|
||||
# the historicals, so it can't have been lodged, so we include it in the old data
|
||||
|
|
@ -277,7 +280,7 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
'original_epc': epc_searcher.newest_epc.copy(),
|
||||
'full_sap_epc': epc_searcher.full_sap_epc.copy(),
|
||||
'old_data': epc_searcher.older_epcs.copy() + [epc],
|
||||
}
|
||||
}, energy_assessment_is_newer
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
|
|
@ -364,8 +367,11 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
|
||||
# If we have an energy assessment in place, that is newer than all of the previous EPCs, we use that.
|
||||
# Otherwise, we use the newest EPC
|
||||
epc_records = create_epc_records(epc_searcher, energy_assessment)
|
||||
|
||||
# energy_assessment_is_newer will tell us if the energy assessment is newer than the newest EPC that
|
||||
# has been publically lodged
|
||||
epc_records, energy_assessment["energy_assessment_is_newer"] = create_epc_records(
|
||||
epc_searcher, energy_assessment
|
||||
)
|
||||
patch = next((
|
||||
x for x in patches if (x["address"] == config["address"]) and (x["postcode"] == config["postcode"])
|
||||
), {})
|
||||
|
|
@ -432,6 +438,7 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
p.get_components(cleaned=cleaned, energy_consumption_client=energy_consumption_client)
|
||||
p.get_spatial_data(uprn_filenames)
|
||||
|
||||
logger.info("Performing solar analysis")
|
||||
# TODO: Tidy this up
|
||||
building_ids = [
|
||||
{
|
||||
|
|
@ -729,10 +736,13 @@ async def trigger_plan(body: PlanTriggerRequest):
|
|||
property_value_increase_ranges[p.id] = valuations
|
||||
|
||||
# Your existing operations
|
||||
property_details_epc = p.get_property_details_epc(
|
||||
portfolio_id=body.portfolio_id, rating_lookup=rating_lookup,
|
||||
)
|
||||
create_property_details_epc(session, property_details_epc)
|
||||
# If we have an energy assessment, which is more recent than the EPC, we don't need to store
|
||||
# the EPC details in the database
|
||||
if not p.energy_assessment_is_newer:
|
||||
property_details_epc = p.get_property_details_epc(
|
||||
portfolio_id=body.portfolio_id, rating_lookup=rating_lookup,
|
||||
)
|
||||
create_property_details_epc(session, property_details_epc)
|
||||
|
||||
update_or_create_property_spatial_details(session, p.uprn, p.spatial)
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,9 @@ class PropertyValuation:
|
|||
200140647: 481_000,
|
||||
200140648: 373_000,
|
||||
200140649: 373_000,
|
||||
# Vander Elliot Intrusive surveys
|
||||
12103116: 1_537_000,
|
||||
12103117: 1_404_000,
|
||||
}
|
||||
|
||||
# We base our valuation uplifts on a number of sources
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ def main():
|
|||
"already_installed_file_path": "",
|
||||
"patches_file_path": "",
|
||||
"non_invasive_recommendations_file_path": "",
|
||||
# "exclusions": [],
|
||||
"exclusions": ["floor_insulation", "fireplace"],
|
||||
"budget": None,
|
||||
}
|
||||
print(body)
|
||||
|
|
|
|||
|
|
@ -211,10 +211,10 @@ def get_u_value_from_s9(thickness, s9, is_loft, is_roof_room, is_thatched):
|
|||
if is_roof_room:
|
||||
# We re-map the thickness
|
||||
thickness_map = {
|
||||
"below average": 50,
|
||||
"average": 100,
|
||||
"above average": 270,
|
||||
"none": 0,
|
||||
"below average": "50",
|
||||
"average": "100",
|
||||
"above average": "270",
|
||||
"none": "0",
|
||||
}
|
||||
thickness = thickness_map[thickness]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue