Skip to content

Commit

Permalink
source-genesys: add logging to conversations
Browse files Browse the repository at this point in the history
Since we haven't been able to test with a production Genesys account,
it'll be nice to have logging to monitor the progress of the
`conversations` Genesys job in case something we didn't anticipate
happens.
  • Loading branch information
Alex-Bair committed Nov 12, 2024
1 parent 0cfda62 commit df5aec7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source-genesys/source_genesys/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ async def _perform_conversation_job(
"interval": f"{_dt_to_str(start_date)}/{_dt_to_str(end_date)}",
}

log.info(f"Submitting Genesys analytics job for conversations between {start_date} and {end_date}.")

response = CreateJobResponse.model_validate_json(
await http.request(log, url, method="POST", json=body)
)
Expand All @@ -115,8 +117,8 @@ async def _perform_conversation_job(
rate_limiter.delay = 3.0
while state != "FULFILLED":
delay = rate_limiter.delay
log.info(f"Sleeping for {delay} seconds while Genesys analytics job completes. Current Genesys job status is {state}.")
await asyncio.sleep(delay)

response = CheckJobStatusResponse.model_validate_json(
await http.request(log, url)
)
Expand All @@ -137,15 +139,22 @@ async def _perform_conversation_job(
"pageSize": 1000,
}

pageCount = 0
most_recent_start = start_date

while True:
response = JobResultsResponse.model_validate_json(
await http.request(log, url, params=params)
)
pageCount += 1

conversations = response.conversations
for conversation in conversations:
most_recent_start = conversation.conversationStart
yield conversation

log.info(f"Processed page {pageCount} containing conversations starting on or before {most_recent_start}.")

cursor = response.cursor
if not cursor:
break
Expand Down

0 comments on commit df5aec7

Please sign in to comment.