mirror of
https://github.com/Hestia-Homes/insight.git
synced 2026-06-30 13:10:44 +00:00
test it works for one
This commit is contained in:
parent
8db3b47e2b
commit
995a5e353d
2 changed files with 20 additions and 16 deletions
|
|
@ -1,14 +1,6 @@
|
|||
#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)
|
||||
|
||||
#df = hubspot_data.generate_df_via_product_type("Empty Cavity - ECO4")
|
||||
|
||||
|
||||
#one = df.iloc(0)
|
||||
|
||||
from dashboard.service
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import logging
|
|||
import asyncio
|
||||
from hubspot.crm.associations import ApiException
|
||||
import hubspot
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class HubSpotClientAsync:
|
||||
API_CONCURRENCY = asyncio.Semaphore(5) # globally limit concurrency
|
||||
|
|
@ -298,7 +300,7 @@ class HubSpotClientAsync:
|
|||
return results
|
||||
|
||||
async def get_expected_commencement_history(self, deal_id: str):
|
||||
"""Fetch historical values for expected_commencement_date."""
|
||||
"""Fetch JSON-serializable historical values for expected_commencement_date."""
|
||||
deal = await self._run(
|
||||
self.client.crm.deals.basic_api.get_by_id,
|
||||
deal_id,
|
||||
|
|
@ -306,6 +308,16 @@ class HubSpotClientAsync:
|
|||
properties_with_history=["expected_commencement_date"]
|
||||
)
|
||||
|
||||
return deal.properties_with_history.get("expected_commencement_date", [])
|
||||
|
||||
history = deal.properties_with_history.get("expected_commencement_date", [])
|
||||
|
||||
json_ready_history = []
|
||||
for entry in history:
|
||||
safe_entry = {}
|
||||
for key, val in entry.items():
|
||||
if isinstance(val, datetime):
|
||||
safe_entry[key] = val.isoformat()
|
||||
else:
|
||||
safe_entry[key] = val
|
||||
json_ready_history.append(safe_entry)
|
||||
|
||||
return json_ready_history
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue