push to this branch

This commit is contained in:
Jun-te Kim 2025-07-24 09:51:15 +00:00
parent 4ff30fd8ef
commit c6ec1eac5d
3 changed files with 59 additions and 1 deletions

View file

@ -206,7 +206,7 @@ class HubSpotClient():
after = response.paging.next.after
all_deals = []
for deal in found_deals:
for i,deal in enumerate(found_deals):
domna_id, landlord_id, uprn = self.get_domna_and_landlord_id(deal.id)
try:
deal_name = deal.properties['dealname']
@ -226,6 +226,9 @@ class HubSpotClient():
domna_id = domna_id,
uprn = uprn,
))
if i > 1:
# Break after just for speed
break
except Exception as e:
def format_error_note(e):
note_text = "⚠️ <b>Automated Verification Failed:</b><br><br>"

View file

@ -0,0 +1,53 @@
import os
from pprint import pprint
os.environ["SHAREPOINT_CLIENT_ID"] = "895e3b77-b1d7-43ec-b18f-dcfe07cdfeaf"
os.environ["SHAREPOINT_CLIENT_SECRET"] = "SOf8Q~-is4wdQiqvEEm9FlJQRAY9ELGaj5Qz-a6E"
os.environ["SHAREPOINT_TENANT_ID"] = "c3f7519c-2719-4547-af04-6da6cbfd8f8f"
os.environ["SOUTH_COAST_INSULATION_SERVICE_SHAREPOINT_ID"] = "b5a51507-9427-4ee0-b03e-90ec7681e2d3"
os.environ["JJC_SERVICE_SHAREPOINT_ID"] = "7fdd0485-bbf3-4b29-b30f-98c81c2a6284"
from etl.hubSpotClient.hubspot import DealStage, HubSpotClient
from etl.surveyedData.surveryedData import surveyedDataProcessor
from etl.scraper.scraper import SharePointScraper, SharePointInstaller
from etl.utils.utils import get_sharepoint_path
def string_to_installer(installer):
if installer.upper() == "J & J CRUMP":
return SharePointInstaller.JJC
elif installer.upper() == "SCIS":
return SharePointInstaller.SOUTH_COAST_INSULATION
elif installer.upper() == "SGEC":
return SharePointInstaller.JJC
else:
return None
# Local development
os.environ["DATABASE_URL"] = "postgresql://postgres:makingwarmhomes@db:5432/postgres"
hubspotClient = HubSpotClient()
# Gets all deals and puts it into a SubmissionInfoFromDeal class
# KHALIM - I ADDED A SCRIPT TO ONLY DOWNLOAD 1 deal for speed sake
deals = hubspotClient.get_deals_from_deal_stage(DealStage.SURVEYED_COMPLETE_NEEDS_SIGN_OFF)
for deal in deals:
sharepoint_url = deal.submission_folder_path
installer = string_to_installer(deal.installer)
sp = SharePointScraper(installer)
path = get_sharepoint_path(sharepoint_url)
files = sp.download_files_from_path(path)
sdp = surveyedDataProcessor("fake address", files)
# Class Object for EPR Summary Informaiton ( Transform )
sdp.epr_summary_information
# File path to epr
sdp.epr_summary_information_file_path
break

View file

@ -43,6 +43,7 @@ class surveyedDataProcessor():
self.hubspot_deal_id = None
self.epr_with_data = None
self.epr_summary_information = None
self.epr_summary_information_file_path = None
self.full_sap_xml = None
self.lig_sap_xml = None
self.rd_sap_xml = None
@ -69,6 +70,7 @@ class surveyedDataProcessor():
self.epr_with_data = pdf.get_reader()
elif pdf.type == ReportType.ENERGY_PERFORMANCE_REPORT_SUMMARY_INFORMATION:
self.epr_summary_information = pdf.get_reader()
self.epr_summary_information_file_path = file
elif file.lower().endswith('.xml'):
xml = xmlReader(file)