refactor(so-connector): optimize api calls with $select and filtering [31188f42]
This commit is contained in:
@@ -43,7 +43,10 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
# Fallback/Deep Lookup & Fetch JobTitle if missing
|
||||
if person_id:
|
||||
try:
|
||||
person_details = so_client.get_person(person_id)
|
||||
person_details = so_client.get_person(
|
||||
person_id,
|
||||
select=["JobTitle", "Title", "Contact/ContactId", "FirstName", "LastName", "UserDefinedFields", "Position"]
|
||||
)
|
||||
if person_details:
|
||||
if not job_title:
|
||||
job_title = person_details.get("JobTitle") or person_details.get("Title")
|
||||
@@ -96,7 +99,7 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
if "contact" in event_low and not person_id:
|
||||
logger.info(f"Company event detected. Triggering cascade for all persons of Contact {contact_id}.")
|
||||
try:
|
||||
persons = so_client.search(f"Person?$filter=contact/contactId eq {contact_id}")
|
||||
persons = so_client.search(f"Person?$select=PersonId&$filter=contact/contactId eq {contact_id}")
|
||||
if persons:
|
||||
q = JobQueue()
|
||||
for p in persons:
|
||||
@@ -114,7 +117,10 @@ def process_job(job, so_client: SuperOfficeClient):
|
||||
contact_details = None
|
||||
|
||||
try:
|
||||
contact_details = so_client.get_contact(contact_id)
|
||||
contact_details = so_client.get_contact(
|
||||
contact_id,
|
||||
select=["Name", "UrlAddress", "Urls", "UserDefinedFields", "Address", "OrgNr"]
|
||||
)
|
||||
if not contact_details:
|
||||
raise ValueError(f"Contact {contact_id} not found (API returned None)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user