From 70e159d9db826eacba811eed5d7f33dc06ec6714 Mon Sep 17 00:00:00 2001 From: "C. Weaver" Date: Sat, 29 Jun 2024 22:04:32 -0400 Subject: [PATCH] Add an annotation recording when the message was ingested --- archive/decision_api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/archive/decision_api.py b/archive/decision_api.py index f36e73d..6df7a4f 100644 --- a/archive/decision_api.py +++ b/archive/decision_api.py @@ -21,6 +21,7 @@ ################# import bson +from datetime import datetime, timezone, timedelta import logging import uuid import zlib @@ -68,6 +69,9 @@ def get_annotations(message, headers=[], public: bool=True, direct_upload: bool= Return: A dictionary of annotations """ + ingest_time = datetime.now(timezone.utc) + # convert to a unix timestamp, and then to milliseconds + its = int((receive_time-datetime(1970, 1, 1, tzinfo=timezone.utc))/timedelta(milliseconds=1)) annotations = {} text_uuid, is_client_uuid = get_text_uuid(headers) annotations["con_text_uuid"] = text_uuid @@ -75,6 +79,7 @@ def get_annotations(message, headers=[], public: bool=True, direct_upload: bool= annotations["con_message_crc32"] = zlib.crc32(message) annotations["public"] = public annotations["direct_upload"] = direct_upload + annotations["ingest_time"] = its return annotations