Add env variable to control Gong start time

This commit is contained in:
Weves 2023-11-01 14:08:19 -07:00 committed by Chris Weaver
parent 5c9c70dffb
commit 0b07d615b1
2 changed files with 17 additions and 1 deletions

View File

@ -138,6 +138,8 @@ CONFLUENCE_CONNECTOR_LABELS_TO_SKIP = [
if ignored_tag
]
GONG_CONNECTOR_START_TIME = os.environ.get("GONG_CONNECTOR_START_TIME")
#####
# Query Configs
#####

View File

@ -9,6 +9,7 @@ from typing import cast
import requests
from danswer.configs.app_configs import CONTINUE_ON_CONNECTOR_FAILURE
from danswer.configs.app_configs import GONG_CONNECTOR_START_TIME
from danswer.configs.app_configs import INDEX_BATCH_SIZE
from danswer.configs.constants import DocumentSource
from danswer.connectors.interfaces import GenerateDocumentsOutput
@ -262,9 +263,21 @@ class GongConnector(LoadConnector, PollConnector):
def poll_source(
self, start: SecondsSinceUnixEpoch, end: SecondsSinceUnixEpoch
) -> GenerateDocumentsOutput:
# if this env variable is set, don't start from a timestamp before the specified
# start time
# TODO: remove this once this is globally available
if GONG_CONNECTOR_START_TIME:
special_start_datetime = datetime.fromisoformat(GONG_CONNECTOR_START_TIME)
special_start_datetime = special_start_datetime.replace(tzinfo=timezone.utc)
else:
special_start_datetime = datetime.fromtimestamp(0, tz=timezone.utc)
start_datetime = max(
datetime.fromtimestamp(start, tz=timezone.utc), special_start_datetime
)
# Because these are meeting start times, the meeting needs to end and be processed
# so adding a 1 day buffer and fetching by default till current time
start_datetime = datetime.fromtimestamp(start, tz=timezone.utc)
start_one_day_offset = start_datetime - timedelta(days=1)
start_time = start_one_day_offset.isoformat()
end_time = (
@ -273,6 +286,7 @@ class GongConnector(LoadConnector, PollConnector):
else None
)
logger.info(f"Fetching Gong calls between {start_time} and {end_time}")
return self._fetch_calls(start_time, end_time)