Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-gladly: use AwareDatetime for timestamp fields #1316

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions source-gladly/source_gladly/api.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions source-gladly/source_gladly/models.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -57,6 +57,6 @@ class Context(BaseDocument, extra="allow"):

id: str
type: str
timestamp: str
timestamp: AwareDatetime
initiator: Initiator
content: Content
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -288,6 +289,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -445,6 +447,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -602,6 +605,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -759,6 +763,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -916,6 +921,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down Expand Up @@ -1073,6 +1079,7 @@
"type": "string"
},
"timestamp": {
"format": "date-time",
"title": "Timestamp",
"type": "string"
},
Expand Down
Loading