mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
added the deletion of condition report
This commit is contained in:
parent
629211d206
commit
9bae34e617
6 changed files with 318 additions and 126 deletions
|
|
@ -0,0 +1,73 @@
|
|||
"""add general information class
|
||||
|
||||
Revision ID: 771a2bc48ac2
|
||||
Revises: f2f205448dff
|
||||
Create Date: 2025-06-18 14:56:08.762223
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '771a2bc48ac2'
|
||||
down_revision: Union[str, None] = 'f2f205448dff'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('generalinformation',
|
||||
sa.Column('id', sa.Uuid(), nullable=False),
|
||||
sa.Column('assessor_details_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('inspection_and_project_id', sa.Uuid(), nullable=False),
|
||||
sa.Column('the_property_id', sa.Uuid(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['assessor_details_id'], ['assessordetails.id'], ),
|
||||
sa.ForeignKeyConstraint(['inspection_and_project_id'], ['inspectionandproject.id'], ),
|
||||
sa.ForeignKeyConstraint(['the_property_id'], ['theproperty.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.add_column('conditionreport', sa.Column('general_information_id', sa.Uuid(), nullable=True))
|
||||
op.drop_constraint('conditionreport_general_condition_id_fkey', 'conditionreport', type_='foreignkey')
|
||||
op.drop_constraint('conditionreport_assessor_details_id_fkey', 'conditionreport', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'conditionreport', 'generalinformation', ['general_information_id'], ['id'])
|
||||
op.drop_column('conditionreport', 'general_condition_id')
|
||||
op.drop_column('conditionreport', 'assessor_details_id')
|
||||
op.add_column('externalelevation', sa.Column('are_there_any_signs_of_water_penetration_caused_by_failed_rainwater_goods_or_pipework', sa.Boolean(), nullable=False))
|
||||
op.add_column('externalelevation', sa.Column('are_there_any_visible_signs_of_cracking_to_the_existing_external_finish', sa.Boolean(), nullable=False))
|
||||
op.drop_column('externalelevation', 'water_penetration_from_failed_rainwater_goods')
|
||||
op.drop_column('externalelevation', 'cracking_to_external_finish_visible')
|
||||
op.add_column('propertyaccess', sa.Column('is_there_restricted_space_for_contractors_to_access_the_wall_area', sa.Boolean(), nullable=False))
|
||||
op.add_column('propertyaccess', sa.Column('is_there_restricted_space_for_contractors_to_access_the_roof_area', sa.Boolean(), nullable=False))
|
||||
op.add_column('propertyaccess', sa.Column('is_there_more_than_1_point_5_meters_in_width_to_fence_or_neighbouring_boundary_along_the_full_gable_elevation', sa.Boolean(), nullable=False))
|
||||
op.drop_column('propertyaccess', 'sufficient_boundary_width')
|
||||
op.drop_column('propertyaccess', 'restricted_wall_access')
|
||||
op.drop_column('propertyaccess', 'restricted_roof_access')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('propertyaccess', sa.Column('restricted_roof_access', sa.BOOLEAN(), autoincrement=False, nullable=False))
|
||||
op.add_column('propertyaccess', sa.Column('restricted_wall_access', sa.BOOLEAN(), autoincrement=False, nullable=False))
|
||||
op.add_column('propertyaccess', sa.Column('sufficient_boundary_width', sa.BOOLEAN(), autoincrement=False, nullable=False))
|
||||
op.drop_column('propertyaccess', 'is_there_more_than_1_point_5_meters_in_width_to_fence_or_neighbouring_boundary_along_the_full_gable_elevation')
|
||||
op.drop_column('propertyaccess', 'is_there_restricted_space_for_contractors_to_access_the_roof_area')
|
||||
op.drop_column('propertyaccess', 'is_there_restricted_space_for_contractors_to_access_the_wall_area')
|
||||
op.add_column('externalelevation', sa.Column('cracking_to_external_finish_visible', sa.BOOLEAN(), autoincrement=False, nullable=False))
|
||||
op.add_column('externalelevation', sa.Column('water_penetration_from_failed_rainwater_goods', sa.BOOLEAN(), autoincrement=False, nullable=False))
|
||||
op.drop_column('externalelevation', 'are_there_any_visible_signs_of_cracking_to_the_existing_external_finish')
|
||||
op.drop_column('externalelevation', 'are_there_any_signs_of_water_penetration_caused_by_failed_rainwater_goods_or_pipework')
|
||||
op.add_column('conditionreport', sa.Column('assessor_details_id', sa.UUID(), autoincrement=False, nullable=True))
|
||||
op.add_column('conditionreport', sa.Column('general_condition_id', sa.UUID(), autoincrement=False, nullable=True))
|
||||
op.drop_constraint(None, 'conditionreport', type_='foreignkey')
|
||||
op.create_foreign_key('conditionreport_assessor_details_id_fkey', 'conditionreport', 'assessordetails', ['assessor_details_id'], ['id'])
|
||||
op.create_foreign_key('conditionreport_general_condition_id_fkey', 'conditionreport', 'generalconditionheatingsystem', ['general_condition_id'], ['id'])
|
||||
op.drop_column('conditionreport', 'general_information_id')
|
||||
op.drop_table('generalinformation')
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
"""delete everythign and start again
|
||||
|
||||
Revision ID: 881142a89edb
|
||||
Revises: 771a2bc48ac2
|
||||
Create Date: 2025-06-18 15:38:53.955796
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '881142a89edb'
|
||||
down_revision: Union[str, None] = '771a2bc48ac2'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("DROP TABLE conditionreport CASCADE")
|
||||
op.execute("DROP TABLE generalinformation CASCADE")
|
||||
op.execute("DROP TABLE theproperty CASCADE")
|
||||
op.execute("DROP TABLE assessordetails CASCADE")
|
||||
op.execute("DROP TABLE inspectionandproject CASCADE")
|
||||
op.execute("DROP TABLE propertyaccess CASCADE")
|
||||
op.execute("DROP TABLE externalelevation CASCADE")
|
||||
op.execute("DROP TABLE generalconditionheatingsystem CASCADE")
|
||||
op.execute("DROP TABLE heating_from_condition_report CASCADE")
|
||||
op.execute("DROP TABLE mainheatingone CASCADE")
|
||||
op.execute("DROP TABLE mainheatingtwo CASCADE")
|
||||
op.execute("DROP TABLE secondaryheating CASCADE")
|
||||
op.execute("DROP TABLE conservatoryoroutbuilding CASCADE")
|
||||
op.execute("DROP TABLE elevation CASCADE")
|
||||
op.execute("DROP TABLE elevationinfo CASCADE")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('inspectionandproject',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('inspection_date', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='inspectionandproject_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('elevation',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('protected_conservatory_or_aonb', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('material_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_visible_signs_of_existing_wall_insulation', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('does_the_existing_ground_level_on_any_elevation_bridge_the_dpc', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='elevation_pkey')
|
||||
)
|
||||
op.create_table('mainheatingone',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('as_defined_by', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('fuel', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='mainheatingone_pkey')
|
||||
)
|
||||
op.create_table('assessordetails',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('assessor_name_and_id', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('elmhurst_id', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='assessordetails_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('elevationinfo',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('elevation_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('cavity_wall_depth', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_insulation_present', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('insulation_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='elevationinfo_pkey')
|
||||
)
|
||||
op.create_table('externalelevation',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('structural_defects_of_elevation', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('does_any_structural_defect_need_resolving_before_retrofit', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_signs_of_water_penetration_caused_by_failed_rainw', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_visible_signs_of_movement', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_visible_signs_of_cracking_to_the_existing_externa', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='externalelevation_pkey')
|
||||
)
|
||||
op.create_table('conditionreport',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('project_site_name', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('property_reference_code', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('property_address', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('postcode', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('inspection_id', sa.UUID(), autoincrement=False, nullable=True),
|
||||
sa.Column('property_id', sa.UUID(), autoincrement=False, nullable=True),
|
||||
sa.Column('general_information_id', sa.UUID(), autoincrement=False, nullable=True),
|
||||
sa.ForeignKeyConstraint(['inspection_id'], ['inspectionandproject.id'], name='conditionreport_inspection_id_fkey'),
|
||||
sa.ForeignKeyConstraint(['property_id'], ['theproperty.id'], name='conditionreport_property_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='conditionreport_pkey')
|
||||
)
|
||||
op.create_table('theproperty',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('house_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('on_which_floor_is_the_flat_located', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_a_corridor', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_it_heated', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('it_there_a_balcony', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('classification_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('orientation_front_elevation', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('orientation_in_degrees_front_elevation', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('exposure_zone', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('main_wall_construction', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='theproperty_pkey'),
|
||||
postgresql_ignore_search_path=False
|
||||
)
|
||||
op.create_table('generalconditionheatingsystem',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_the_heating_system_in_working_order', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('does_the_occupant_have_a_smart_meter', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_smart_monitoring_devices', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_the_gas_and_electricity_meters_accessible', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('dual_or_single_electric_meter', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='generalconditionheatingsystem_pkey')
|
||||
)
|
||||
op.create_table('mainheatingtwo',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_a_main_heating_two', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='mainheatingtwo_pkey')
|
||||
)
|
||||
op.create_table('generalinformation',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('assessor_details_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('inspection_and_project_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('the_property_id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.ForeignKeyConstraint(['assessor_details_id'], ['assessordetails.id'], name='generalinformation_assessor_details_id_fkey'),
|
||||
sa.ForeignKeyConstraint(['inspection_and_project_id'], ['inspectionandproject.id'], name='generalinformation_inspection_and_project_id_fkey'),
|
||||
sa.ForeignKeyConstraint(['the_property_id'], ['theproperty.id'], name='generalinformation_the_property_id_fkey'),
|
||||
sa.PrimaryKeyConstraint('id', name='generalinformation_pkey')
|
||||
)
|
||||
op.create_table('heating_from_condition_report',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('room_stat_in_temperature_in_celsius', sa.VARCHAR(), autoincrement=False, nullable=True),
|
||||
sa.Column('room_stat_location', sa.VARCHAR(), autoincrement=False, nullable=True),
|
||||
sa.Column('is_the_heating_pattern_known', sa.VARCHAR(), autoincrement=False, nullable=True),
|
||||
sa.PrimaryKeyConstraint('id', name='heating_from_condition_report_pkey')
|
||||
)
|
||||
op.create_table('propertyaccess',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_road_restriction_in_the_locality', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_on_street_parking_available', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('are_there_any_overhead_wires_or_cables', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_the_access_gated', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_restricted_space_for_contractors_to_access_the_wall_ar', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_restricted_space_for_contractors_to_access_the_roof_ar', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_more_than_1_point_5_meters_in_width_to_fence_or_neighb', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_access_to_the_rear_provided_by_use_of_a_ginnel', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_access_to_the_rear_provided_by_use_of_a_secured_alleyway', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='propertyaccess_pkey')
|
||||
)
|
||||
op.create_table('secondaryheating',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_a_secondary_heating', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('fuel', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('electric_heating_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.Column('gas_heating_type', sa.VARCHAR(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='secondaryheating_pkey')
|
||||
)
|
||||
op.create_table('conservatoryoroutbuilding',
|
||||
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_a_conservatory', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_a_cellar_present', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.Column('is_there_an_outbuilding', sa.BOOLEAN(), autoincrement=False, nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name='conservatoryoroutbuilding_pkey')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -8,7 +8,7 @@ pprint(sdp.condition_report.master_obj)
|
|||
|
||||
init_db()
|
||||
with get_db_session() as db_session:
|
||||
sdp.load_condiion_report(db_session)
|
||||
sdp.load_condition_report(db_session)
|
||||
|
||||
# TODO: add the ability to add document type, and sharepoint or s3 link so we can process access it again
|
||||
# Terraform lambda set up to start this job from a s3 link
|
||||
|
|
@ -6,109 +6,3 @@ 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
|
||||
|
||||
|
||||
class Elevation(BaseModel, table=True):
|
||||
protected_conservatory_or_aonb: bool
|
||||
material_type: str
|
||||
are_there_any_visible_signs_of_existing_wall_insulation: str
|
||||
does_the_existing_ground_level_on_any_elevation_bridge_the_dpc: bool
|
||||
|
||||
|
||||
class PropertyAccess(BaseModel, table=True):
|
||||
are_there_any_road_restriction_in_the_locality: bool
|
||||
is_on_street_parking_available: bool
|
||||
are_there_any_overhead_wires_or_cables: bool
|
||||
is_the_access_gated: bool
|
||||
is_there_restricted_space_for_contractors_to_access_the_wall_area: bool
|
||||
is_there_restricted_space_for_contractors_to_access_the_roof_area: bool
|
||||
is_there_more_than_1_point_5_meters_in_width_to_fence_or_neighbouring_boundary_along_the_full_gable_elevation: bool
|
||||
is_access_to_the_rear_provided_by_use_of_a_ginnel: bool
|
||||
is_access_to_the_rear_provided_by_use_of_a_secured_alleyway: bool
|
||||
|
||||
|
||||
class ExternalElevation(BaseModel, table=True):
|
||||
structural_defects_of_elevation: str
|
||||
does_any_structural_defect_need_resolving_before_retrofit: bool
|
||||
are_there_any_signs_of_water_penetration_caused_by_failed_rainwater_goods_or_pipework: bool
|
||||
are_there_any_visible_signs_of_movement: bool
|
||||
are_there_any_visible_signs_of_cracking_to_the_existing_external_finish: bool
|
||||
|
||||
|
||||
class ConservatoryOrOutbuilding(BaseModel, table=True):
|
||||
is_there_a_conservatory: bool
|
||||
is_there_a_cellar_present: bool
|
||||
is_there_an_outbuilding: bool
|
||||
|
||||
|
||||
class GeneralConditionHeatingSystem(BaseModel, table=True):
|
||||
is_the_heating_system_in_working_order: bool
|
||||
does_the_occupant_have_a_smart_meter: bool
|
||||
are_there_any_smart_monitoring_devices: bool
|
||||
are_the_gas_and_electricity_meters_accessible: bool
|
||||
dual_or_single_electric_meter: str
|
||||
|
||||
|
||||
class SecondaryHeating(BaseModel, table=True):
|
||||
is_there_a_secondary_heating: bool
|
||||
fuel: str
|
||||
electric_heating_type: str
|
||||
gas_heating_type: str
|
||||
|
||||
|
||||
class MainHeatingOne(BaseModel, table=True):
|
||||
as_defined_by: str
|
||||
fuel: str
|
||||
type: str
|
||||
|
||||
|
||||
class MainHeatingTwo(BaseModel, table=True):
|
||||
is_there_a_main_heating_two: bool
|
||||
|
||||
|
||||
class HeatingFromConditionReport(BaseModel, table=True):
|
||||
__tablename__ = 'heating_from_condition_report'
|
||||
room_stat_in_temperature_in_celsius: Optional[str] = None
|
||||
room_stat_location: Optional[str] = None
|
||||
is_the_heating_pattern_known: Optional[str] = None
|
||||
|
||||
|
||||
class ConditionReport(BaseModel, table=True):
|
||||
project_site_name: str
|
||||
property_reference_code: str
|
||||
property_address: str
|
||||
postcode: str
|
||||
|
||||
assessor_details_id: Optional[uuid.UUID] = Field(default=None, foreign_key="assessordetails.id")
|
||||
inspection_id: Optional[uuid.UUID] = Field(default=None, foreign_key="inspectionandproject.id")
|
||||
property_id: Optional[uuid.UUID] = Field(default=None, foreign_key="theproperty.id")
|
||||
general_condition_id: Optional[uuid.UUID] = Field(default=None, foreign_key="generalconditionheatingsystem.id")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ from etl.models.conditionReport import (
|
|||
MainHeatingOne,
|
||||
MainHeatingTwo,
|
||||
HeatingFromConditionReport,
|
||||
ConditionReport
|
||||
ConditionReport,
|
||||
GeneralInformation,
|
||||
MainElevation,
|
||||
)
|
||||
|
||||
from etl.models.topLevel import(
|
||||
|
|
@ -57,7 +59,7 @@ class surveyedDataProcessor():
|
|||
elif pdf.type == ReportType.OSMOSIS_CONDITION_PAS_2035_REPORT:
|
||||
self.condition_report = pdf.get_reader()
|
||||
|
||||
def load_condiion_report(self, db_session):
|
||||
def load_condition_report(self, db_session):
|
||||
# My task to complete load
|
||||
# [] general_information = self.get_section_1()
|
||||
# [] access_and_elevations = self.get_section_2()
|
||||
|
|
@ -93,25 +95,75 @@ class surveyedDataProcessor():
|
|||
# main_elevation=main_elevation,
|
||||
# elevations=elevations
|
||||
# )
|
||||
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
|
||||
db_session,
|
||||
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,
|
||||
)
|
||||
print("assessor details loaded please check")
|
||||
|
||||
def load_general_information_from_condition_report(self, db_session):
|
||||
# Assessors Information
|
||||
self.upsert_record(
|
||||
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,
|
||||
},
|
||||
lookup_field=None
|
||||
)
|
||||
|
||||
general_information = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=AssessorDetails,
|
||||
|
||||
|
||||
|
||||
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,
|
||||
)
|
||||
|
||||
|
||||
# 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")
|
||||
|
||||
def load_pre_site_notes_summary_table(self, db_session):
|
||||
summary_data = self.pre_site_note.survey_information.model_dump()
|
||||
return self.upsert_record(
|
||||
|
|
@ -135,7 +187,7 @@ class surveyedDataProcessor():
|
|||
lookup_field="UPRN",
|
||||
)
|
||||
|
||||
def get_attribute_and_load(self, obj, attr_string, pydanticModel, db_session):
|
||||
def get_attribute_and_load(self, obj, attr_string, pydanticModel, db_session, lookup_field=None):
|
||||
found = getattr(obj, attr_string, None)
|
||||
if found:
|
||||
print(f"Uploading to data base {found}")
|
||||
|
|
@ -146,7 +198,7 @@ class surveyedDataProcessor():
|
|||
db_session=db_session,
|
||||
model_class=pydanticModel,
|
||||
data_dict=found.model_dump(),
|
||||
lookup_field=None
|
||||
lookup_field=lookup_field
|
||||
)
|
||||
return db
|
||||
return None
|
||||
|
|
@ -178,7 +230,7 @@ class surveyedDataProcessor():
|
|||
if data:
|
||||
mainheating2 = self.upsert_record(
|
||||
db_session=db_session,
|
||||
model_class=Heating,
|
||||
model_class=HeatingFromPreSiteNotes,
|
||||
data_dict=data,
|
||||
lookup_field=None,
|
||||
additional_fields= {"controls_id": mainheating2controls.id},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
#poetry run alembic revision --autogenerate -m "rename ntables"
|
||||
|
||||
|
||||
poetry run alembic upgrade head
|
||||
#poetry run alembic revision --autogenerate -m "delete everythign and start again"
|
||||
poetry run alembic upgrade +1
|
||||
|
||||
# See which hash I'm at
|
||||
#poetry run alembic current
|
||||
|
|
@ -9,7 +7,6 @@ poetry run alembic upgrade head
|
|||
# downgrade one version
|
||||
#poetry run alembic upgrade head
|
||||
#poetry run alembic downgrade -1
|
||||
#poetry run alembic upgrade +1
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue