mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from typing import List
|
|
|
|
from backend.app.db.models.condition import (
|
|
AspectConditionModel,
|
|
ElementModel,
|
|
PropertyConditionSurveyModel,
|
|
)
|
|
from backend.condition.domain.property_condition_survey import PropertyConditionSurvey
|
|
|
|
|
|
class ConditionPostgres:
|
|
|
|
def insert_surveys(surveys: List[PropertyConditionSurvey]) -> None:
|
|
raise NotImplementedError
|
|
|
|
@staticmethod
|
|
def map_survey_to_model(
|
|
survey: PropertyConditionSurvey,
|
|
) -> PropertyConditionSurveyModel:
|
|
survey_model = PropertyConditionSurveyModel(
|
|
uprn=survey.uprn,
|
|
date=survey.date,
|
|
source=survey.source,
|
|
elements=[],
|
|
)
|
|
|
|
for element in survey.elements:
|
|
element_model = ElementModel(
|
|
element_type=element.element_type,
|
|
element_instance=element.element_instance,
|
|
aspect_conditions=[],
|
|
)
|
|
|
|
for aspect in element.aspect_conditions:
|
|
aspect_model = AspectConditionModel(
|
|
aspect_type=aspect.aspect_type,
|
|
aspect_instance=aspect.aspect_instance,
|
|
value=aspect.value,
|
|
quantity=aspect.quantity,
|
|
install_date=aspect.install_date,
|
|
renewal_year=aspect.renewal_year,
|
|
comments=aspect.comments,
|
|
)
|
|
|
|
element_model.aspect_conditions.append(aspect_model)
|
|
|
|
survey_model.elements.append(element_model)
|
|
|
|
return survey_model
|