From 2993813111cc83d8460aedf1971f163a033370d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Far=C3=ADas=20Santana?= Date: Fri, 15 Sep 2023 16:50:32 +0200 Subject: [PATCH] refactor: Format all datetimes as isoformat --- posthog/temporal/workflows/batch_exports.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/posthog/temporal/workflows/batch_exports.py b/posthog/temporal/workflows/batch_exports.py index 5fe3cde5e123a..c79262a0fe86a 100644 --- a/posthog/temporal/workflows/batch_exports.py +++ b/posthog/temporal/workflows/batch_exports.py @@ -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, @@ -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(), }