fix gitlab-connector - wrong datetime format (#1559)

This commit is contained in:
NP 2024-06-04 19:41:19 +02:00 committed by Hagen O'Neill
parent 9e0b6aa531
commit 8dfba97c09

View File

@ -6,6 +6,7 @@ from datetime import timezone
from typing import Any
import gitlab
import pytz
from danswer.configs.app_configs import INDEX_BATCH_SIZE
from danswer.configs.constants import DocumentSource
@ -114,12 +115,14 @@ class GitlabConnector(LoadConnector, PollConnector):
doc_batch: list[Document] = []
for mr in mr_batch:
mr.updated_at = datetime.strptime(
mr.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ"
mr.updated_at, "%Y-%m-%dT%H:%M:%S.%f%z"
)
if start is not None and mr.updated_at < start:
if start is not None and mr.updated_at < start.replace(
tzinfo=pytz.UTC
):
yield doc_batch
return
if end is not None and mr.updated_at > end:
if end is not None and mr.updated_at > end.replace(tzinfo=pytz.UTC):
continue
doc_batch.append(_convert_merge_request_to_document(mr))
yield doc_batch
@ -131,13 +134,17 @@ class GitlabConnector(LoadConnector, PollConnector):
doc_batch = []
for issue in issue_batch:
issue.updated_at = datetime.strptime(
issue.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ"
issue.updated_at, "%Y-%m-%dT%H:%M:%S.%f%z"
)
if start is not None and issue.updated_at < start:
yield doc_batch
return
if end is not None and issue.updated_at > end:
continue
if start is not None:
start = start.replace(tzinfo=pytz.UTC)
if issue.updated_at < start:
yield doc_batch
return
if end is not None:
end = end.replace(tzinfo=pytz.UTC)
if issue.updated_at > end:
continue
doc_batch.append(_convert_issue_to_document(issue))
yield doc_batch