add back end to do script in new way

This commit is contained in:
Jun-te Kim 2025-11-26 08:33:57 +00:00
parent c249ebb62d
commit 8db3b47e2b
2 changed files with 27 additions and 7 deletions

View file

@ -1,8 +1,14 @@
from dashboard.services.file_manager import FileManager
from dashboard.services.json_reader import jsonReader
s3 = FileManager()
#from dashboard.services.file_manager import FileManager
#from dashboard.services.json_reader import jsonReader
#s3 = FileManager()
key, path, data = s3.download_and_read_latest()
hubspot_data = jsonReader(data)
#key, path, data = s3.download_and_read_latest()
#hubspot_data = jsonReader(data)
#df = hubspot_data.generate_df_via_product_type("Empty Cavity - ECO4")
#one = df.iloc(0)
from dashboard.service
df = hubspot_data.generate_df_via_product_type("Empty Cavity - ECO4")

View file

@ -128,6 +128,9 @@ class HubSpotClientAsync:
deal_info = dict(deal.properties)
deal_info["deal_id"] = deal_id
expected_commencement_history = await self.get_expected_commencement_history(deal_id)
deal_info["expected_commencement_history"] = expected_commencement_history
line_items = await self.from_deal_get_line_items(deal_id)
company_id = await self.from_deal_get_associated_company_id(deal_id)
company_info = await self.get_company_information(company_id) if company_id else {}
@ -293,5 +296,16 @@ class HubSpotClientAsync:
results.append(await task)
return results
async def get_expected_commencement_history(self, deal_id: str):
"""Fetch historical values for expected_commencement_date."""
deal = await self._run(
self.client.crm.deals.basic_api.get_by_id,
deal_id,
properties=[],
properties_with_history=["expected_commencement_date"]
)
return deal.properties_with_history.get("expected_commencement_date", [])