mirror of
https://github.com/Hestia-Homes/insight.git
synced 2026-06-08 11:17:25 +00:00
save current
This commit is contained in:
parent
e031b8b128
commit
868d40bd5a
2 changed files with 16 additions and 11 deletions
|
|
@ -3,7 +3,6 @@ import asyncio
|
|||
from hubspot.crm.associations import ApiException
|
||||
import hubspot
|
||||
|
||||
|
||||
class HubSpotClientAsync:
|
||||
API_CONCURRENCY = asyncio.Semaphore(5) # globally limit concurrency
|
||||
RATE_LIMIT_DELAY = 0.25 # 4 requests/sec → safe
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ from pprint import pprint
|
|||
from collections import defaultdict
|
||||
import pandas as pd
|
||||
|
||||
from enum import Enum
|
||||
|
||||
class ProductType(Enum):
|
||||
EMPTY_CAVITY_ECO_4 = "Empty Cavity - ECO4"
|
||||
|
||||
|
||||
|
||||
|
|
@ -37,6 +41,7 @@ class jsonReader:
|
|||
if deals['attempts'] != []:
|
||||
row = self._return_df_from_deal_info(deals, product_type)
|
||||
rows.append(row)
|
||||
break
|
||||
|
||||
if rows:
|
||||
return pd.concat(rows, ignore_index=True)
|
||||
|
|
@ -45,16 +50,17 @@ class jsonReader:
|
|||
|
||||
|
||||
def _return_df_from_deal_info(self, deal, product_type):
|
||||
print(deal)
|
||||
data = {
|
||||
"submission_date": deal.get("submission_date", None),
|
||||
"expected_commencement_date": deal.get("expected_commencement_date", None),
|
||||
"work_type": product_type,
|
||||
"price": next(
|
||||
(item["price"] for item in deal["line_items"] if product_type in item["name"]),
|
||||
None
|
||||
)
|
||||
}
|
||||
for attempts in deal["attempts"]:
|
||||
data = {
|
||||
"submission_date": deal.get("submission_date", None),
|
||||
"expected_commencement_date": deal.get("expected_commencement_date", None),
|
||||
"work_type": product_type,
|
||||
"price": next(
|
||||
(item["price"] for item in deal["line_items"] if product_type in item["name"]),
|
||||
None
|
||||
)
|
||||
}
|
||||
|
||||
return pd.DataFrame([data])
|
||||
|
||||
def find_all_job_with_line_item(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue