mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-08 11:17:29 +00:00
add the url
This commit is contained in:
parent
c7dc758d28
commit
7a08cf2003
2 changed files with 11 additions and 4 deletions
|
|
@ -82,8 +82,11 @@ for pipeline in pipelines.results:
|
|||
if deals["deal_owner"]:
|
||||
owner_name = hubspot.get_owner_name_from_id(deals['deal_owner'])
|
||||
|
||||
portal_id = 145275138
|
||||
|
||||
notes_data[pipeline_name].append({
|
||||
"Deal Name": deal_name.upper(),
|
||||
"Deal URL": f"https://app.hubspot.com/contacts/{portal_id}/records/0-3/{deals["deal_id"]}",
|
||||
"Deal Owner": owner_name,
|
||||
"Deal Stage": stage.label.upper(),
|
||||
"Value": deals["value"],
|
||||
|
|
@ -92,7 +95,7 @@ for pipeline in pipelines.results:
|
|||
"Notes Week 3": "\n---\n".join(deal_notes_by_week["Week 3"]),
|
||||
})
|
||||
print("delay to not bombard the server")
|
||||
time.sleep(2)
|
||||
time.sleep(1)
|
||||
|
||||
# Create Excel Workbook
|
||||
wb = Workbook()
|
||||
|
|
@ -101,7 +104,7 @@ wb.remove(wb.active)
|
|||
for pipeline, deals in notes_data.items():
|
||||
ws = wb.create_sheet(title=pipeline[:31])
|
||||
|
||||
headers = ["Deal Name", "Deal Owner", "Deal Stage", "Value", "Notes Week 1", "Notes Week 2", "Notes Week 3"]
|
||||
headers = ["Deal Name", "Deal URL", "Deal Owner", "Deal Stage", "Value", "Notes Week 1", "Notes Week 2", "Notes Week 3"]
|
||||
ws.append(headers)
|
||||
for cell in ws[1]:
|
||||
cell.font = Font(bold=True)
|
||||
|
|
@ -122,12 +125,14 @@ for pipeline, deals in notes_data.items():
|
|||
# Add main deal row + first notes
|
||||
ws.append([
|
||||
row["Deal Name"],
|
||||
row["Deal URL"],
|
||||
row["Deal Owner"],
|
||||
row["Deal Stage"],
|
||||
row["Value"],
|
||||
*first_notes
|
||||
])
|
||||
|
||||
|
||||
# Determine max number of remaining notes
|
||||
max_additional_notes = max(len(week_notes[week]) for week in range(1, 4)) - 1
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class HubSpotClient():
|
|||
|
||||
def get_owner_name_from_id(self, owner_id):
|
||||
owner = self.client.crm.owners.owners_api.get_by_id(owner_id)
|
||||
time.sleep(0.5)
|
||||
time.sleep(1)
|
||||
first_name = owner.first_name or ""
|
||||
last_name = owner.last_name or ""
|
||||
return f"{first_name} {last_name}".strip()
|
||||
|
|
@ -31,7 +31,7 @@ class HubSpotClient():
|
|||
def get_deal_name_by_id(self, deal_id):
|
||||
try:
|
||||
deal = self.client.crm.deals.basic_api.get_by_id(deal_id)
|
||||
time.sleep(0.5)
|
||||
time.sleep(1)
|
||||
return deal.properties.get("dealname", "No deal name")
|
||||
except Exception as e:
|
||||
return "Unknown Deal" # Fallback if the deal name is not found
|
||||
|
|
@ -56,6 +56,7 @@ class HubSpotClient():
|
|||
)
|
||||
# Call the search API
|
||||
response = self.client.crm.objects.search_api.do_search(object_type="notes", public_object_search_request=search_request)
|
||||
time.sleep(1)
|
||||
|
||||
# Add the results to the found_notes list
|
||||
found_notes.extend(response.results)
|
||||
|
|
@ -100,6 +101,7 @@ class HubSpotClient():
|
|||
after=after,
|
||||
)
|
||||
response = self.client.crm.deals.search_api.do_search(search_request)
|
||||
time.sleep(1)
|
||||
found_deals.extend(response.results)
|
||||
if not response.paging or not response.paging.next:
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue