mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
filling constituency
This commit is contained in:
parent
d45059e40d
commit
cf3b603a36
5 changed files with 17 additions and 17 deletions
|
|
@ -728,14 +728,14 @@ class Property:
|
|||
energy_consumption_client.data = None
|
||||
|
||||
heating_prediction = (
|
||||
float(condition_data["space_heating_kwh"]) if condition_data["space_heating_kwh"]
|
||||
float(condition_data["space_heating_kwh"]) if condition_data.get("space_heating_kwh") is not None
|
||||
else energy_consumption_client.score_new_data(
|
||||
new_data=scoring_df, target="heating_kwh"
|
||||
)[0]
|
||||
)
|
||||
|
||||
hot_water_prediction = (
|
||||
float(condition_data["water_heating_kwh"]) if condition_data["water_heating_kwh"]
|
||||
float(condition_data["water_heating_kwh"]) if condition_data.get("water_heating_kwh") is not None
|
||||
else energy_consumption_client.score_new_data(
|
||||
new_data=scoring_df, target="hot_water_kwh"
|
||||
)[0]
|
||||
|
|
@ -1051,18 +1051,18 @@ class Property:
|
|||
|
||||
# We can update the number of floors if we have this information in the condition data
|
||||
self.number_of_floors = int(self.energy_assessment_condition_data["number_of_floors"]) \
|
||||
if condition_data["number_of_floors"] is not None \
|
||||
if condition_data.get("number_of_floors") is not None \
|
||||
else self.number_of_floors
|
||||
|
||||
self.perimeter = float(self.energy_assessment_condition_data["perimeter"]) \
|
||||
if condition_data["perimeter"] is not None \
|
||||
if condition_data.get("perimeter") is not None \
|
||||
else estimate_perimeter(
|
||||
floor_area=self.floor_area / self.number_of_floors,
|
||||
num_rooms=self.number_of_rooms / self.number_of_floors
|
||||
)
|
||||
|
||||
self.insulation_wall_area = float(self.energy_assessment_condition_data["insulation_wall_area"]) \
|
||||
if condition_data["insulation_wall_area"] is not None \
|
||||
if condition_data.get("insulation_wall_area") is not None \
|
||||
else estimate_external_wall_area(
|
||||
num_floors=self.number_of_floors,
|
||||
floor_height=self.floor_height,
|
||||
|
|
@ -1071,13 +1071,9 @@ class Property:
|
|||
)
|
||||
|
||||
self.insulation_floor_area = float(self.energy_assessment_condition_data["main_dwelling_ground_floor_area"]) \
|
||||
if condition_data["main_dwelling_ground_floor_area"] is not None \
|
||||
if condition_data.get("main_dwelling_ground_floor_area") is not None \
|
||||
else self.floor_area / self.number_of_floors
|
||||
|
||||
# self.pitched_roof_area = esimtate_pitched_roof_area(
|
||||
# floor_area=self.insulation_floor_area, floor_height=self.floor_height
|
||||
# )
|
||||
|
||||
def set_floor_level(self):
|
||||
self.floor_level = (
|
||||
FLOOR_LEVEL_MAP[self.data["floor-level"]]
|
||||
|
|
@ -1177,7 +1173,7 @@ class Property:
|
|||
condition_data = self.energy_assessment_condition_data.copy()
|
||||
|
||||
self.number_of_windows = int(condition_data["number_of_windows"]) \
|
||||
if condition_data["number_of_windows"] is not None \
|
||||
if condition_data.get("number_of_windows") is not None \
|
||||
else estimate_windows(
|
||||
property_type=self.data["property-type"],
|
||||
built_form=self.data["built-form"],
|
||||
|
|
@ -1187,7 +1183,7 @@ class Property:
|
|||
)
|
||||
|
||||
self.windows_area = float(condition_data["windows_area"]) \
|
||||
if condition_data["windows_area"] is not None \
|
||||
if condition_data.get("windows_area") is not None \
|
||||
else None
|
||||
|
||||
def set_energy_source(self):
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ def get_latest_assessment_by_uprn(session: Session, uprn: int) -> Optional[Energ
|
|||
# Query the EnergyAssessment model, filter by uprn, order by inspection_date in descending order
|
||||
latest_assessment = session.query(EnergyAssessment).filter_by(uprn=uprn).order_by(
|
||||
desc(EnergyAssessment.inspection_date)).first()
|
||||
return latest_assessment.to_dict() if latest_assessment else latest_assessment.empty_response()
|
||||
|
||||
return latest_assessment.to_dict() if latest_assessment else EnergyAssessment.empty_response()
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from sqlalchemy import Column, Integer, BigInteger, Text, Float, DateTime, Boolean
|
||||
from sqlalchemy import Column, Integer, BigInteger, Text, Float, DateTime, Boolean, Date
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
|
@ -94,8 +94,8 @@ class EnergyAssessment(Base):
|
|||
hot_water_cost_potential = Column(Text, nullable=False)
|
||||
lighting_cost_current = Column(Text, nullable=False)
|
||||
energy_consumption_current = Column(Text, nullable=False)
|
||||
lodgement_date = Column(DateTime(timezone=True), nullable=False)
|
||||
lodgement_datetime = Column(DateTime(timezone=True), nullable=False)
|
||||
lodgement_date = Column(Date, nullable=False)
|
||||
lodgement_datetime = Column(DateTime(timezone=False), nullable=False)
|
||||
mainheat_description = Column(Text, nullable=False)
|
||||
floor_height = Column(Float, nullable=False)
|
||||
glazed_type = Column(Text, nullable=False)
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ def create_epc_records(epc_searcher: SearchEpc, energy_assessment: dict):
|
|||
# We insert county into the epc, since right now this isn't something that we pull out from the energy
|
||||
# assessment
|
||||
epc["county"] = epc_searcher.newest_epc["county"]
|
||||
epc["constituency"] = epc_searcher.newest_epc["constituency"]
|
||||
|
||||
# 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"]):
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ def main():
|
|||
# We'll need to get the uprn from the folder name, which we can do with EpcSearcher class
|
||||
|
||||
# TODO: Pull out county, as in create_epc_records in the router, we pull it from the latest EPC, but we should
|
||||
# be able to deduce it from just the address
|
||||
# be able to deduce it from just the address. Same for constituency and constituency_label
|
||||
|
||||
# TODO: Store the project code in the database
|
||||
#
|
||||
energy_assessments = list_files_and_subfolders_in_s3_folder(
|
||||
bucket_name=BUCKET, folder_name=f"{SURVEYORS}/{PROJECT_CODE}/"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue