From 61e9664363aaf6e426210d11314f2bb81d8c2d7f Mon Sep 17 00:00:00 2001 From: Alex Bair Date: Wed, 18 Dec 2024 09:05:19 -0500 Subject: [PATCH] source-genesys: fix conversations default param bug 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. --- source-genesys/source_genesys/api.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source-genesys/source_genesys/api.py b/source-genesys/source_genesys/api.py index c92754f263..fa267cec38 100644 --- a/source-genesys/source_genesys/api.py +++ b/source-genesys/source_genesys/api.py @@ -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 = {