Merge pull request #5 from Hestia-Homes/feature/make_dashboard_better_for_one

add attempt type so i know what type of work it is
This commit is contained in:
Jun-te Kim 2025-11-21 16:02:31 +00:00 committed by GitHub
commit 3dc3a53529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 15 deletions

View file

@ -5,9 +5,6 @@ s3 = FileManager()
key, path, data = s3.download_and_read_latest()
hubspot_data = jsonReader(data)
counter, deals = hubspot_data.generate_solar_numbers_df()
counter
deals
df = hubspot_data.generate_df_via_product_type("Empty Cavity - ECO4")
df

View file

@ -273,6 +273,7 @@ class HubSpotClientAsync:
"outcome_surveyor",
"submission_date",
"expected_commencement_date",
"attempt_type",
]
)

View file

@ -1,5 +1,7 @@
from pprint import pprint
from collections import defaultdict
import pandas as pd
@ -29,18 +31,32 @@ class jsonReader:
self.deals_by_line_item[name].append(deal)
self.line_item_names = list(self.deals_by_line_item.keys())
def generate_empty_cavity_numbers_df(self):
count=0
for deals in self.deals_by_line_item["Empty Cavity - ECO4"]:
count +=1
def generate_df_via_product_type(self, product_type):
rows = []
for deals in self.deals_by_line_item[product_type]:
if deals['attempts'] != []:
return count, deals
return count, deals
row = self._return_df_from_deal_info(deals, product_type)
rows.append(row)
if rows:
return pd.concat(rows, ignore_index=True)
else:
return
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
)
}
return pd.DataFrame([data])
def _return_df_from_deal_info(self, deal):
pass
def find_all_job_with_line_item(self):
for i, deal in enumerate(self.raw_data):
if len(deal["line_items"])>0: