Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-genesys: add logging to conversations #2140

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading