mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-01 02:00:48 +02:00
Add env variable to control Gong start time
This commit is contained in:
@ -138,6 +138,8 @@ CONFLUENCE_CONNECTOR_LABELS_TO_SKIP = [
|
|||||||
if ignored_tag
|
if ignored_tag
|
||||||
]
|
]
|
||||||
|
|
||||||
|
GONG_CONNECTOR_START_TIME = os.environ.get("GONG_CONNECTOR_START_TIME")
|
||||||
|
|
||||||
#####
|
#####
|
||||||
# Query Configs
|
# Query Configs
|
||||||
#####
|
#####
|
||||||
|
@ -9,6 +9,7 @@ from typing import cast
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from danswer.configs.app_configs import CONTINUE_ON_CONNECTOR_FAILURE
|
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.app_configs import INDEX_BATCH_SIZE
|
||||||
from danswer.configs.constants import DocumentSource
|
from danswer.configs.constants import DocumentSource
|
||||||
from danswer.connectors.interfaces import GenerateDocumentsOutput
|
from danswer.connectors.interfaces import GenerateDocumentsOutput
|
||||||
@ -262,9 +263,21 @@ class GongConnector(LoadConnector, PollConnector):
|
|||||||
def poll_source(
|
def poll_source(
|
||||||
self, start: SecondsSinceUnixEpoch, end: SecondsSinceUnixEpoch
|
self, start: SecondsSinceUnixEpoch, end: SecondsSinceUnixEpoch
|
||||||
) -> GenerateDocumentsOutput:
|
) -> 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
|
# 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
|
# 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_one_day_offset = start_datetime - timedelta(days=1)
|
||||||
start_time = start_one_day_offset.isoformat()
|
start_time = start_one_day_offset.isoformat()
|
||||||
end_time = (
|
end_time = (
|
||||||
@ -273,6 +286,7 @@ class GongConnector(LoadConnector, PollConnector):
|
|||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.info(f"Fetching Gong calls between {start_time} and {end_time}")
|
||||||
return self._fetch_calls(start_time, end_time)
|
return self._fetch_calls(start_time, end_time)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user