diff --git a/backend/src/dashboard/services/hubspot_client_async.py b/backend/src/dashboard/services/hubspot_client_async.py index f8b8f45..0b52ae7 100644 --- a/backend/src/dashboard/services/hubspot_client_async.py +++ b/backend/src/dashboard/services/hubspot_client_async.py @@ -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 diff --git a/backend/src/dashboard/services/json_reader.py b/backend/src/dashboard/services/json_reader.py index 6935cb4..03cc470 100644 --- a/backend/src/dashboard/services/json_reader.py +++ b/backend/src/dashboard/services/json_reader.py @@ -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):