From 44f4ae331a356a95ae36abd271f3fbf0a4a9054a Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 8 May 2025 16:01:35 +0000 Subject: [PATCH] database almost complete, one or two things left --- etl/surveyedData/surveryedData.py | 72 ++++++++++++++++++++++++++++-- etl/transform/preSiteNoteTypes.py | 73 ++++++++++++++++++++++++++----- 2 files changed, 132 insertions(+), 13 deletions(-) diff --git a/etl/surveyedData/surveryedData.py b/etl/surveyedData/surveryedData.py index 19fb0ff..ea66566 100644 --- a/etl/surveyedData/surveryedData.py +++ b/etl/surveyedData/surveryedData.py @@ -5,7 +5,9 @@ from etl.transform.preSiteNoteTypes import ( AssessorInfo, CompanyInfo, PreSiteNotesSummaryInfo, PreSiteNote, PropertyDescription, Dimension, HeatingType, Heating, HeatingSystemControls, - OtherDetails, WindTurbine, PhotovoltaicPanel + OtherDetails, WindTurbine, PhotovoltaicPanel, FlueGasHeatRecoverySystem, ShowerAndBaths, + SolarWaterHeating, HotWaterCylinder, WaterHeating, Lighting, VentilationAndCooling, + Door, ) import uuid @@ -113,14 +115,78 @@ class surveyedDataProcessor(): db_session ) + #photo_volatic_panel photo_volatic_panel = self.get_attribute_and_load( self.pre_site_note.property_description, "photovoltaicPanel", PhotovoltaicPanel, db_session, ) - - + + #fluegasheatrecoverysystem + flue_gas_heat_recovery_system = self.get_attribute_and_load( + self.pre_site_note.property_description, + "flueGasHeatRecoverySystem", + FlueGasHeatRecoverySystem, + db_session, + ) + + #shower and baths + shower_and_baths = self.get_attribute_and_load( + self.pre_site_note.property_description, + "showerAndBaths", + ShowerAndBaths, + db_session, + ) + + #solar water heating + solar_water_heating = self.get_attribute_and_load( + self.pre_site_note.property_description, + "solarWaterHeating", + SolarWaterHeating, + db_session, + ) + + # hotwatercycling + hot_water_cyclinder = self.get_attribute_and_load( + self.pre_site_note.property_description, + "hotWaterCylinder", + HotWaterCylinder, + db_session, + ) + + # water heating + water_heating = self.get_attribute_and_load( + self.pre_site_note.property_description, + "waterHeating", + WaterHeating, + db_session, + ) + + # lighting + lighting = self.get_attribute_and_load( + self.pre_site_note.property_description, + "lighting", + Lighting, + db_session, + ) + + # ventilation and cooling + ventilation_and_cooling = self.get_attribute_and_load( + self.pre_site_note.property_description, + "ventilationAndCooling", + VentilationAndCooling, + db_session, + ) + + # door + door = self.get_attribute_and_load( + self.pre_site_note.property_description, + "door", + Door, + db_session, + ) + def load_company_table(self, db_session): company_data = self.pre_site_note.company_information.model_dump() diff --git a/etl/transform/preSiteNoteTypes.py b/etl/transform/preSiteNoteTypes.py index 478d7e5..231971a 100644 --- a/etl/transform/preSiteNoteTypes.py +++ b/etl/transform/preSiteNoteTypes.py @@ -83,7 +83,7 @@ class Floors(BaseModel): floor_insulation_thickness_mm: Optional[float] = -1 u_value_known: bool -class Door(BaseModel): +class Door(BaseModel, table=True): no_of_doors: int no_of_insulated_doors: int u_value_w_m2_k: Optional[str] @@ -100,12 +100,12 @@ class AssessorInfo(BaseModel, table=True): pre_site_notes: List["PreSiteNote"] = Relationship(back_populates="assessor") -class VentilationAndCooling(BaseModel): +class VentilationAndCooling(BaseModel, table=True): no_of_open_fireplaces: int ventilation_type: str space_cooling_system_present: bool -class Lighting(BaseModel): +class Lighting(BaseModel, table=True): total_no_of_light_fittings: int total_no_of_lel_fittings: int @@ -140,25 +140,25 @@ class HeatingType(BaseModel, table=True): heating_type: str fuel_type: str -class WaterHeating(BaseModel): +class WaterHeating(BaseModel, table=True): heating_type: str fuel_type: str -class HotWaterCylinder(BaseModel): +class HotWaterCylinder(BaseModel, table=True): volume: str insulation_type: str insulation_thickness: str thermostat: bool -class SolarWaterHeating(BaseModel): +class SolarWaterHeating(BaseModel, table=True): solar_water_heating_details_known: bool -class ShowerAndBaths(BaseModel): +class ShowerAndBaths(BaseModel, table=True): no_of_rooms_with_baths_and_or_shower: int no_of_rooms_with_mixer_shower_and_no_baths: int no_of_rooms_with_mixer_shower_and_baths: int -class FlueGasHeatRecoverySystem(BaseModel): +class FlueGasHeatRecoverySystem(BaseModel, table=True): fghrs_present: bool class PhotovoltaicPanel(BaseModel, table=True): @@ -194,6 +194,7 @@ class PropertyDescription(BaseModel): built_form: str detachment_or_position: str no_of_main_property: int + conservatory: bool no_of_extension_1: Optional[int] = 0 no_of_extension_2: Optional[int] = 0 no_of_extension_3: Optional[int] = 0 @@ -205,18 +206,71 @@ class PropertyDescription(BaseModel): percentage_of_draught_proofed: int terrain_type: str main_property: PropertyDetail + + ex1_property: Optional[PropertyDetail] = None ex2_property: Optional[PropertyDetail] = None ex3_property: Optional[PropertyDetail] = None ex4_property: Optional[PropertyDetail] = None - conservatory: bool + + # Door + door_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="door.id" + ) door: Optional[Door] + + + # ventilation and cooling + vetilation_and_cooling_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="ventilationandcooling.id" + ) ventilationAndCooling: Optional[VentilationAndCooling] + + + # lighting + lighting_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="lighting.id" + ) lighting: Optional[Lighting] + + + # water heating + water_heating_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="waterheating.id" + ) waterHeating: Optional[WaterHeating] + + + #hotwatercylinder + hot_water_cylinder_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="hotwatercylinder.id" + ) hotWaterCylinder: Optional[HotWaterCylinder] + + #solarAndWaterHeating + solar_water_heating_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="solarwaterheating.id" + ) solarWaterHeating: Optional[SolarWaterHeating] + + # shower and baths + shower_and_baths_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="showerandbaths.id" + ) showerAndBaths: Optional[ShowerAndBaths] + + # flueGasHeatRecoverySystem + flue_gas_heat_recovery_system_id: Optional[uuid.UUID] = Field( + default=None, + foreign_key="fluegasheatrecoverysystem.id" + ) flueGasHeatRecoverySystem: Optional[FlueGasHeatRecoverySystem] # photovolaticPanel @@ -255,7 +309,6 @@ class PropertyDescription(BaseModel): default=None, foreign_key="heatingtype.id" ) - secondaryHeatingType: Optional[HeatingType] class Insulation(BaseModel):