Skip to content

Commit

Permalink
source-genesys: fix conversations default param bug
Browse files Browse the repository at this point in the history
In Python, default parameters are evaluated once when the function
definition is executed. This means that a default param of
`datetime.now(tz=UTC)` is only evaluated when the program starts up,
and that same value is used for each subsequent function call. Meaning
that within the connector, `_perform_conversation_job` was using a fixed
end date and not incrementing it over time.

Now, a default value of `None` is used in `_perform_conversation_job`
to indicate that the current time should be used as the end date.
  • Loading branch information
Alex-Bair committed Dec 18, 2024
1 parent a72d6ac commit 61e9664
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source-genesys/source_genesys/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,17 @@ async def _perform_conversation_job(
domain: str,
log: Logger,
start_date: datetime,
end_date: datetime = datetime.now(tz=UTC),
end_date: datetime | None = None,
) -> AsyncGenerator[Conversation, None]:
"""
Requests the Genesys API to perform an async job & paginates through the results.
API docs - https://developer.genesys.cloud/routing/conversations/conversations-apis#post-api-v2-analytics-conversations-details-jobs
"""

if end_date is None:
end_date = datetime.now(tz=UTC)

# Submit job.
url = f"{COMMON_API}.{domain}/api/v2/analytics/conversations/details/jobs"
body = {
Expand Down

0 comments on commit 61e9664

Please sign in to comment.