mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
datbase work sve so far
This commit is contained in:
parent
c4299c02f1
commit
3ca373175c
3 changed files with 32 additions and 5 deletions
|
|
@ -2,12 +2,14 @@ from etl.hubSpotClient.hubspot import HubSpotClient, DealStage
|
|||
from etl.surveyPrice.surveyPrice import SurveyPrice
|
||||
from etl.surveyedData.surveryedData import surveyedDataProcessor
|
||||
from etl.scraper.scraper import SharePointScraper, SharePointInstaller
|
||||
from etl.db.db import get_db_session, init_db
|
||||
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
class HubspotTodb():
|
||||
def __init__(self):
|
||||
init_db()
|
||||
self.hubspot = HubSpotClient()
|
||||
self.deals_in_hubspot = None
|
||||
self.data_in_sharepoint = []
|
||||
|
|
@ -80,10 +82,16 @@ class HubspotTodb():
|
|||
|
||||
for add, file_loc in data_loc.items():
|
||||
self.data_in_sharepoint.append(surveyedDataProcessor(add, file_loc))
|
||||
|
||||
def print_address(self):
|
||||
|
||||
def load_all(self):
|
||||
self.gather_data_from_each_sharepoint()
|
||||
for dp in self.data_in_sharepoint:
|
||||
print(dp.address)
|
||||
with get_db_session() as session:
|
||||
self.load_pre_site_note(session)
|
||||
session.commit()
|
||||
|
||||
def load_pre_site_note(self, db_session):
|
||||
for surveyedData in self.data_in_sharepoint:
|
||||
surveyedData.load_assessor_table(db_session)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ from etl.db.hubSpotLoad import HubspotTodb
|
|||
|
||||
dbLoader = HubspotTodb()
|
||||
|
||||
dbLoader.print_address()
|
||||
dbLoader.load_all()
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from etl.pdfReader.pdfReaderToText import pdfReaderToText
|
||||
from etl.pdfReader.reportType import ReportType
|
||||
import math
|
||||
from etl.transform.preSiteNoteTypes import AssessorInfo
|
||||
|
||||
class surveyedDataProcessor():
|
||||
def __init__(self, address, files):
|
||||
|
|
@ -22,6 +23,24 @@ class surveyedDataProcessor():
|
|||
elif pdf.type == ReportType.CHARTED_SURVEYOR_REPORT:
|
||||
self.csr = pdf.get_reader()
|
||||
|
||||
def load_assessor_table(self, db_session):
|
||||
assessor_data = self.pre_site_note.assessor_information.__dict__
|
||||
accreditation_number = assessor_data.get('accreditation_number')
|
||||
|
||||
existing_assessor = db_session.query(AssessorInfo).filter_by(
|
||||
accreditation_number=accreditation_number
|
||||
).first()
|
||||
|
||||
if existing_assessor:
|
||||
# Update existing record
|
||||
for key, value in assessor_data.items():
|
||||
setattr(existing_assessor, key, value)
|
||||
else:
|
||||
# Insert new record
|
||||
db_session.add(AssessorInfo(**assessor_data))
|
||||
|
||||
db_session.commit()
|
||||
|
||||
def get_insulation_info(self):
|
||||
if self.csr:
|
||||
if self.csr.insulation_info:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue