From c6ec1eac5da5c5d51634638cede00cfd2dd0cf53 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 24 Jul 2025 09:51:15 +0000 Subject: [PATCH] push to this branch --- etl/hubSpotClient/hubspot.py | 5 +- ...pull_data_from_hubspot_and_ideally_push.py | 53 +++++++++++++++++++ etl/surveyedData/surveryedData.py | 2 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 etl/quick_script_to_pull_data_from_hubspot_and_ideally_push.py diff --git a/etl/hubSpotClient/hubspot.py b/etl/hubSpotClient/hubspot.py index 3b4913e..269862c 100644 --- a/etl/hubSpotClient/hubspot.py +++ b/etl/hubSpotClient/hubspot.py @@ -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 = "⚠️ Automated Verification Failed:

" diff --git a/etl/quick_script_to_pull_data_from_hubspot_and_ideally_push.py b/etl/quick_script_to_pull_data_from_hubspot_and_ideally_push.py new file mode 100644 index 0000000..34924cc --- /dev/null +++ b/etl/quick_script_to_pull_data_from_hubspot_and_ideally_push.py @@ -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 + + + diff --git a/etl/surveyedData/surveryedData.py b/etl/surveyedData/surveryedData.py index f75b112..a88b8da 100644 --- a/etl/surveyedData/surveryedData.py +++ b/etl/surveyedData/surveryedData.py @@ -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)