Skip to content

Commit

Permalink
refactor: Format all datetimes as isoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Sep 15, 2023
1 parent 0b62ee2 commit 2993813
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions posthog/temporal/workflows/batch_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ def iter_batch_records(batch) -> typing.Generator[dict[str, typing.Any], None, N
elements = json.dumps(record.get("elements_chain").decode())

record = {
"created_at": record.get("created_at").strftime("%Y-%m-%d %H:%M:%S.%f"),
"created_at": record.get("created_at").isoformat(),
"distinct_id": record.get("distinct_id").decode(),
"elements": elements,
"elements_chain": record.get("elements_chain").decode(),
"event": record.get("event").decode(),
"inserted_at": record.get("inserted_at").strftime("%Y-%m-%d %H:%M:%S.%f")
if record.get("inserted_at")
else None,
"inserted_at": record.get("inserted_at").isoformat() if record.get("inserted_at") else None,
"ip": properties.get("$ip", None) if properties else None,
"person_id": record.get("person_id").decode(),
"person_properties": json.loads(person_properties) if person_properties else None,
Expand All @@ -159,7 +157,7 @@ def iter_batch_records(batch) -> typing.Generator[dict[str, typing.Any], None, N
"properties": properties,
"site_url": properties.get("$current_url", None) if properties else None,
"team_id": record.get("team_id"),
"timestamp": record.get("timestamp").strftime("%Y-%m-%d %H:%M:%S.%f"),
"timestamp": record.get("timestamp").isoformat(),
"uuid": record.get("uuid").decode(),
}

Expand Down

0 comments on commit 2993813

Please sign in to comment.