makeing db loading possible

This commit is contained in:
Jun-te Kim 2025-04-28 09:38:01 +00:00
parent 102281f08d
commit 581d9862e7
5 changed files with 20 additions and 7 deletions

View file

@ -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
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

View file

@ -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

View file

@ -18,4 +18,5 @@ class SubmissionInfoFromDeal(BaseModel):
post_sap_score: int
existing_wall_insulation: str
no_of_wet_rooms: int
installer: str
installer: str
submission_folder_path: str

View file

@ -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()

View file

@ -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()