From 581d9862e7813a5532b78371ed79613ef3367d69 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Mon, 28 Apr 2025 09:38:01 +0000 Subject: [PATCH] makeing db loading possible --- etl/db/load.py | 13 ++++++++++--- etl/hubSpotClient/hubspot.py | 2 ++ etl/hubSpotClient/types.py | 3 ++- etl/hubspot_to_db.py | 5 +++-- etl/surveyPrice/surveyPrice.py | 4 +++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/etl/db/load.py b/etl/db/load.py index ec9145b..e402073 100644 --- a/etl/db/load.py +++ b/etl/db/load.py @@ -1,5 +1,12 @@ +from etl.hubSpotClient.hubspot import HubSpotClient, DealStage +from etl.surveyPrice.surveyPrice import SurveyPrice - -class loadToDb(): +class HubspotTodb(): def __init__(self): - pass \ No newline at end of file + self.hubspot = HubSpotClient() + self.deals_in_hubspot = None + + def get_all_deals(self): + sp = SurveyPrice() + self.deals_in_hubspot = sp.get_all_surveys_from_hubspot() + return self.deals_in_hubspot diff --git a/etl/hubSpotClient/hubspot.py b/etl/hubSpotClient/hubspot.py index 90c551b..eb982fa 100644 --- a/etl/hubSpotClient/hubspot.py +++ b/etl/hubSpotClient/hubspot.py @@ -136,6 +136,7 @@ class HubSpotClient(): "domna_survey_post_sap", "existing_wall_insulation", "installer", + "submission_folder", ], limit=200, after=after, @@ -157,6 +158,7 @@ class HubSpotClient(): existing_wall_insulation=deal.properties.get("existing_wall_insulation") if deal.properties.get("existing_wall_insulation") else "None", no_of_wet_rooms=int(deal.properties["number_of_wet_rooms_needing_ventilation"]), installer=deal.properties["installer"], + submission_folder_path = deal.properties["submission_folder"], )) return all_deals diff --git a/etl/hubSpotClient/types.py b/etl/hubSpotClient/types.py index b4dd30e..7d069df 100644 --- a/etl/hubSpotClient/types.py +++ b/etl/hubSpotClient/types.py @@ -18,4 +18,5 @@ class SubmissionInfoFromDeal(BaseModel): post_sap_score: int existing_wall_insulation: str no_of_wet_rooms: int - installer: str \ No newline at end of file + installer: str + submission_folder_path: str \ No newline at end of file diff --git a/etl/hubspot_to_db.py b/etl/hubspot_to_db.py index 867cc37..626bd0c 100644 --- a/etl/hubspot_to_db.py +++ b/etl/hubspot_to_db.py @@ -1,12 +1,13 @@ import os - 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" -p +from etl.db.load import HubspotTodb +dbLoader = HubspotTodb() +dbLoader.get_all_deals() \ No newline at end of file diff --git a/etl/surveyPrice/surveyPrice.py b/etl/surveyPrice/surveyPrice.py index db85108..4a5ffd2 100644 --- a/etl/surveyPrice/surveyPrice.py +++ b/etl/surveyPrice/surveyPrice.py @@ -14,7 +14,7 @@ class SurveyPrice(): self.master_rate_card_path = None self.all_hubspot_submissions = None self.all_survey_info_from_sharepoint = None - self.download_price_card() + self.required_sheets = [ 'JJC - EMPTIES', @@ -148,6 +148,7 @@ class SurveyPrice(): "HUBSPOT_POST_INSTALL_SAP_SCORE": deal.post_sap_score, "HUBSPOT_INSTALLER": deal.installer, "HUBSPOT_WETROOMS": deal.no_of_wet_rooms, + "HUBSPOT_SHAREPOINT_PATH": deal.submission_folder_path, }) self.all_hubspot_submissions = pd.DataFrame(all_deals) @@ -318,6 +319,7 @@ class SurveyPrice(): return merged_df def calculate_all_price(self): + self.download_price_card() self.get_all_surveys_from_hubspot() self.get_all_surveyed_data_from_sharepoint() submission_data = self.merge_hub_spot_and_survey_information()