diff --git a/source-gladly/source_gladly/api.py b/source-gladly/source_gladly/api.py index b1eac8d9c0..00a81d3f07 100644 --- a/source-gladly/source_gladly/api.py +++ b/source-gladly/source_gladly/api.py @@ -1,10 +1,9 @@ from datetime import datetime from logging import Logger -from typing import Any, AsyncGenerator +from typing import AsyncGenerator from estuary_cdk.http import HTTPSession from estuary_cdk.capture.common import LogCursor -from pydantic import AwareDatetime from .models import Event @@ -28,9 +27,8 @@ async def fetch_events( max_ts = log_cursor async for line in http.request_lines(log, url, params=params): event = Event.model_validate_json(line) - ts = datetime.fromisoformat(event.timestamp) - if ts > max_ts: - max_ts = ts + if event.timestamp > max_ts: + max_ts = event.timestamp event.meta_ = Event.Meta(op="c") yield event diff --git a/source-gladly/source_gladly/models.py b/source-gladly/source_gladly/models.py index f6dbfa5880..0f5b137161 100644 --- a/source-gladly/source_gladly/models.py +++ b/source-gladly/source_gladly/models.py @@ -1,5 +1,5 @@ from enum import StrEnum -from pydantic import BaseModel, Field +from pydantic import AwareDatetime, BaseModel, Field from typing import TYPE_CHECKING from estuary_cdk.capture.common import ( @@ -57,6 +57,6 @@ class Context(BaseDocument, extra="allow"): id: str type: str - timestamp: str + timestamp: AwareDatetime initiator: Initiator content: Content diff --git a/source-gladly/tests/snapshots/source_gladly_tests_test_snapshots__discover__stdout.json b/source-gladly/tests/snapshots/source_gladly_tests_test_snapshots__discover__stdout.json index 7ad8ea01af..13335665ca 100644 --- a/source-gladly/tests/snapshots/source_gladly_tests_test_snapshots__discover__stdout.json +++ b/source-gladly/tests/snapshots/source_gladly_tests_test_snapshots__discover__stdout.json @@ -131,6 +131,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -288,6 +289,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -445,6 +447,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -602,6 +605,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -759,6 +763,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -916,6 +921,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" }, @@ -1073,6 +1079,7 @@ "type": "string" }, "timestamp": { + "format": "date-time", "title": "Timestamp", "type": "string" },