mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
save current working copy
This commit is contained in:
parent
9bae34e617
commit
68d6dbda44
2 changed files with 82 additions and 69 deletions
|
|
@ -6,3 +6,45 @@ from datetime import datetime
|
|||
|
||||
class BaseModel(SQLModel):
|
||||
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
|
||||
|
||||
class AssessorDetails(BaseModel, table=True):
|
||||
assessor_name_and_id: str
|
||||
elmhurst_id: str
|
||||
|
||||
class InspectionAndProject(BaseModel, table=True):
|
||||
inspection_date: str
|
||||
|
||||
class TheProperty(BaseModel, table=True):
|
||||
house_type: str
|
||||
on_which_floor_is_the_flat_located: str
|
||||
is_there_a_corridor: bool
|
||||
is_it_heated: bool
|
||||
it_there_a_balcony: bool
|
||||
classification_type: str
|
||||
orientation_front_elevation: str
|
||||
orientation_in_degrees_front_elevation: str
|
||||
exposure_zone: str
|
||||
main_wall_construction: str
|
||||
|
||||
|
||||
class ElevationInfo(BaseModel, table=True):
|
||||
elevation_type: str
|
||||
cavity_wall_depth: str
|
||||
is_insulation_present: bool
|
||||
insulation_type: str
|
||||
|
||||
elevation_table: Optional["MainElevation"] = Relationship(back_populates="elevation_info")
|
||||
|
||||
class MainElevation(BaseModel, table=True):
|
||||
elevation_info_id: uuid.UUID = Field(foreign_key="elevationinfo.id")
|
||||
|
||||
#SQLAlcemy things
|
||||
elevation_info: ElevationInfo = Relationship(back_populates="elevation_table")
|
||||
|
||||
class Elevation(BaseModel):
|
||||
protected_conservatory_or_aonb: bool
|
||||
material_type: str
|
||||
visible_signs_of_existing_wall_insulation: str
|
||||
ground_level_bridge_the_dpc: bool
|
||||
|
||||
info: List[ElevationInfo] = Relationship(back_populates="")
|
||||
|
|
|
|||
|
|
@ -15,20 +15,8 @@ from pprint import pprint
|
|||
from etl.models.conditionReport import (
|
||||
AssessorDetails,
|
||||
InspectionAndProject,
|
||||
TheProperty,
|
||||
ElevationInfo,
|
||||
Elevation,
|
||||
PropertyAccess,
|
||||
ExternalElevation,
|
||||
ConservatoryOrOutbuilding,
|
||||
GeneralConditionHeatingSystem,
|
||||
SecondaryHeating,
|
||||
MainHeatingOne,
|
||||
MainHeatingTwo,
|
||||
HeatingFromConditionReport,
|
||||
ConditionReport,
|
||||
GeneralInformation,
|
||||
MainElevation,
|
||||
TheProperty, ElevationInfo,
|
||||
MainElevation
|
||||
)
|
||||
|
||||
from etl.models.topLevel import(
|
||||
|
|
@ -98,71 +86,54 @@ class surveyedDataProcessor():
|
|||
self.load_general_information_from_condition_report(db_session)
|
||||
|
||||
def load_general_information_from_condition_report(self, db_session):
|
||||
assessor_details = self.get_attribute_and_load(
|
||||
self.condition_report.master_obj.general_information,
|
||||
"assessor_details",
|
||||
AssessorDetails,
|
||||
db_session,
|
||||
assessors_data = self.condition_report.master_obj.general_information.assessor_details.model_dump()
|
||||
|
||||
assessor_details = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=AssessorDetails,
|
||||
data_dict=assessors_data,
|
||||
lookup_field="elmhurst_id",
|
||||
)
|
||||
inspection_details = self.get_attribute_and_load(
|
||||
self.condition_report.master_obj.general_information,
|
||||
"inspection_and_project",
|
||||
InspectionAndProject,
|
||||
db_session,
|
||||
)
|
||||
the_property = self.get_attribute_and_load(
|
||||
self.condition_report.master_obj.general_information,
|
||||
"the_property",
|
||||
TheProperty,
|
||||
db_session,
|
||||
)
|
||||
inspection_data = self.condition_report.master_obj.general_information.inspection_and_project.model_dump()
|
||||
|
||||
main_elevation_info = self.get_attribute_and_load(
|
||||
self.condition_report.master_obj.general_information.main_elevation,
|
||||
"elevation_info",
|
||||
ElevationInfo,
|
||||
db_session,
|
||||
)
|
||||
|
||||
main_elevation_in_db = self.upsert_record(
|
||||
db_session=db_session
|
||||
model_class=MainElevation,
|
||||
data_dict={
|
||||
"elevation_info_id:": main_elevation_info.id,
|
||||
},
|
||||
inspection_and_project = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=InspectionAndProject,
|
||||
data_dict=inspection_data,
|
||||
lookup_field=None
|
||||
)
|
||||
|
||||
general_information = self.upsert_record(
|
||||
property_data = self.condition_report.master_obj.general_information.the_property.model_dump()
|
||||
the_property = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=GeneralInformation,
|
||||
data_dict={
|
||||
"assessor_details_id": assessor_details.id,
|
||||
"inspection_and_project_id": inspection_details.id,
|
||||
"the_property_id": the_property.id,
|
||||
},
|
||||
lookup_field=None,
|
||||
model_class=TheProperty,
|
||||
data_dict=property_data,
|
||||
lookup_field=None
|
||||
)
|
||||
|
||||
# Main elevation
|
||||
elevation_info = self.condition_report.master_obj.general_information.main_elevation.elevation_info.model_dump()
|
||||
elevation_info = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=ElevationInfo,
|
||||
data_dict=elevation_info,
|
||||
lookup_field=None
|
||||
)
|
||||
main_elevation = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=MainElevation,
|
||||
data_dict={
|
||||
"elevation_info_id": elevation_info.id
|
||||
},
|
||||
lookup_field=None
|
||||
)
|
||||
|
||||
# elevations multiple
|
||||
for i, elevation in enumerate()
|
||||
# Other elevations
|
||||
|
||||
|
||||
# elevations = []
|
||||
# for i,elevation in enumerate(self.condition_report.master_obj.general_information.elevations):
|
||||
# data = elevation.model_dump()
|
||||
|
||||
# elevation_from_db = self.upsert_record(
|
||||
# db_session=db_session,
|
||||
# model_class=ElevationInfo,
|
||||
# data_dict = data
|
||||
# lookup_field=None,
|
||||
# additional_fields={}
|
||||
# )
|
||||
# elevations.append(elevation_from_db.id)
|
||||
|
||||
# pprint(self.condition_report.master_obj.general_information)
|
||||
|
||||
# dimensions.append(dimension.id)
|
||||
# print("Check database please")
|
||||
print("Check database please")
|
||||
|
||||
def load_pre_site_notes_summary_table(self, db_session):
|
||||
summary_data = self.pre_site_note.survey_information.model_dump()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue