mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
rooms have been completed
This commit is contained in:
parent
95cc1821c7
commit
50600b5192
3 changed files with 80 additions and 21 deletions
|
|
@ -191,8 +191,46 @@ class Bedroom(BaseModel, table=True):
|
|||
double_or_single_bedroom: str
|
||||
room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
|
||||
room_info: Optional[RoomInfo] = Relationship()
|
||||
rooms_id: uuid.UUID = Field(foreign_key="rooms.id")
|
||||
rooms: Optional["Rooms"] = Relationship(back_populates="bedrooms")
|
||||
|
||||
|
||||
class Bathroom(BaseModel, table=True):
|
||||
is_this_an_ensuite_bathroom: bool
|
||||
room_info_id: Optional[uuid.UUID] = Field(foreign_key="roominfo.id")
|
||||
room_info: Optional[RoomInfo] = Relationship()
|
||||
room_info: Optional[RoomInfo] = Relationship()
|
||||
|
||||
rooms_id: uuid.UUID = Field(foreign_key="rooms.id")
|
||||
rooms: Optional["Rooms"] = Relationship(back_populates="bathrooms")
|
||||
|
||||
|
||||
class Rooms(BaseModel, table=True):
|
||||
hallway_id: uuid.UUID = Field(foreign_key="hallway.id")
|
||||
hallway: Hallway = Relationship()
|
||||
|
||||
living_room_id: uuid.UUID = Field(foreign_key="livingroom.id")
|
||||
living_room: LivingRoom = Relationship()
|
||||
|
||||
dining_room_id: uuid.UUID = Field(foreign_key="diningroom.id")
|
||||
dining_room: DiningRoom = Relationship()
|
||||
|
||||
kitchen_id: uuid.UUID = Field(foreign_key="kitchen.id")
|
||||
kitchen: Kitchen = Relationship()
|
||||
|
||||
utility_id: uuid.UUID = Field(foreign_key="utility.id")
|
||||
utility: Utility = Relationship()
|
||||
|
||||
wash_chamber_id: uuid.UUID = Field(foreign_key="wc.id")
|
||||
wash_chamber: WC = Relationship()
|
||||
|
||||
landing_id: uuid.UUID = Field(foreign_key="landing.id")
|
||||
landing: Landing = Relationship()
|
||||
|
||||
loft_space_id: uuid.UUID = Field(foreign_key="loftspace.id")
|
||||
loft_space: LoftSpace = Relationship()
|
||||
|
||||
room_in_roof_id: uuid.UUID = Field(foreign_key="roominroof.id")
|
||||
room_in_roof: RoomInRoof = Relationship()
|
||||
|
||||
bedrooms: List[Bedroom] = Relationship(back_populates="rooms")
|
||||
bathrooms: List[Bathroom] = Relationship(back_populates="rooms")
|
||||
|
|
|
|||
|
|
@ -326,7 +326,6 @@ class CompanyInfo(BaseModel, table=True):
|
|||
assessors: List[AssessorInfo] = Relationship(back_populates="company")
|
||||
|
||||
|
||||
|
||||
class Insulation(BaseModel, table=True):
|
||||
type: str
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ from etl.models.conditionReport import (
|
|||
LoftSpace,
|
||||
RoomInRoof,
|
||||
Bedroom,
|
||||
Bathroom
|
||||
Bathroom,
|
||||
Rooms
|
||||
)
|
||||
|
||||
from etl.models.topLevel import(
|
||||
|
|
@ -121,22 +122,41 @@ class surveyedDataProcessor():
|
|||
access_and_elevations = self.load_access_and_elevations_from_condition_report(db_session)
|
||||
rooms = self.load_rooms_from_condition_report(db_session)
|
||||
|
||||
pprint(rooms)
|
||||
|
||||
def load_rooms_from_condition_report(self, db_session):
|
||||
self.load_hallway_from_condition_report(db_session)
|
||||
self.load_living_room_from_condition_report(db_session)
|
||||
self.load_dining_room_from_condition_report(db_session)
|
||||
self.load_kitchen_from_condition_report(db_session)
|
||||
self.load_utility_room_from_condition_report(db_session)
|
||||
self.load_wash_chamber_from_condition_report(db_session)
|
||||
self.load_landing_from_condition_report(db_session)
|
||||
self.load_loft_space_from_condition_report(db_session)
|
||||
self.load_room_in_roof_from_condition_report(db_session)
|
||||
self.load_bedrooms_from_condition_report(db_session)
|
||||
self.load_bathrooms_from_condition_report(db_session)
|
||||
hallway = self.load_hallway_from_condition_report(db_session)
|
||||
living_room = self.load_living_room_from_condition_report(db_session)
|
||||
dining_room = self.load_dining_room_from_condition_report(db_session)
|
||||
kitchen = self.load_kitchen_from_condition_report(db_session)
|
||||
utility_room = self.load_utility_room_from_condition_report(db_session)
|
||||
wash_chamber = self.load_wash_chamber_from_condition_report(db_session)
|
||||
landing = self.load_landing_from_condition_report(db_session)
|
||||
loft_space = self.load_loft_space_from_condition_report(db_session)
|
||||
rir = self.load_room_in_roof_from_condition_report(db_session)
|
||||
|
||||
def load_bathrooms_from_condition_report(self, db_session):
|
||||
rooms = self.upsert_record(
|
||||
model_class=Rooms,
|
||||
data_dict=self.condition_report.master_obj.rooms.model_dump(),
|
||||
db_session=db_session,
|
||||
additional_fields={
|
||||
"hallway_id": hallway.id,
|
||||
"living_room_id": living_room.id,
|
||||
"dining_room_id": dining_room.id,
|
||||
"kitchen_id": kitchen.id,
|
||||
"utility_id": utility_room.id,
|
||||
"wash_chamber_id": wash_chamber.id,
|
||||
"landing_id": landing.id,
|
||||
"loft_space_id": loft_space.id,
|
||||
"room_in_roof_id": rir.id,
|
||||
}
|
||||
)
|
||||
|
||||
bedrooms = self.load_bedrooms_from_condition_report(db_session, rooms.id)
|
||||
bathrooms = self.load_bathrooms_from_condition_report(db_session, rooms.id)
|
||||
|
||||
return rooms
|
||||
|
||||
|
||||
def load_bathrooms_from_condition_report(self, db_session, rooms_id):
|
||||
bathroom_ids = []
|
||||
for i, bathrooms in enumerate(self.condition_report.master_obj.rooms.bathrooms):
|
||||
room_info = self.load_room_info_from_condition_report(
|
||||
|
|
@ -149,12 +169,13 @@ class surveyedDataProcessor():
|
|||
data_dict=bathrooms.model_dump(),
|
||||
additional_fields={
|
||||
"room_info_id": room_info.id,
|
||||
"rooms_id": rooms_id,
|
||||
}
|
||||
)
|
||||
bathroom_ids.append(bathroom.id)
|
||||
return bathroom_ids
|
||||
|
||||
def load_bedrooms_from_condition_report(self, db_session):
|
||||
def load_bedrooms_from_condition_report(self, db_session, rooms_id):
|
||||
bedroom_ids = []
|
||||
for i, bedrooms in enumerate(self.condition_report.master_obj.rooms.bedrooms):
|
||||
room_info = self.load_room_info_from_condition_report(
|
||||
|
|
@ -167,6 +188,7 @@ class surveyedDataProcessor():
|
|||
data_dict=bedrooms.model_dump(),
|
||||
additional_fields={
|
||||
"room_info_id": room_info.id,
|
||||
"rooms_id": rooms_id,
|
||||
}
|
||||
)
|
||||
bedroom_ids.append(bedroom.id)
|
||||
|
|
@ -885,9 +907,9 @@ class surveyedDataProcessor():
|
|||
update_if_exists: bool = False,
|
||||
additional_fields: dict = None
|
||||
):
|
||||
def remove_nested_dicts(data: dict):
|
||||
return {k: v for k, v in data.items() if not isinstance(v, dict)}
|
||||
clean_data = remove_nested_dicts(data_dict)
|
||||
def remove_nested_dicts_and_lists(data: dict):
|
||||
return {k: v for k, v in data.items() if not isinstance(v, (dict, list))}
|
||||
clean_data = remove_nested_dicts_and_lists(data_dict)
|
||||
|
||||
# Merge additional fields if provided
|
||||
if additional_fields:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue