From 66dc57dc450a891f127a4f6ea72652278f54166c Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 3 Aug 2022 07:20:30 +0100 Subject: [PATCH] Handle time vs ts field in data --- core/lib/opensearch.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index 3b4402d..c7e0c45 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -198,12 +198,18 @@ def query_results(request, size=None): element["id"] = item["_id"] # Split the timestamp into date and time - ts = element["ts"] - ts_spl = ts.split("T") - date = ts_spl[0] - time = ts_spl[1] - element["date"] = date - element["time"] = time + if "ts" not in element: + if "time" in element: # will fix data later + ts = element["time"] + del element["time"] + element["ts"] = ts + if "ts" in element: + ts = element["ts"] + ts_spl = ts.split("T") + date = ts_spl[0] + time = ts_spl[1] + element["date"] = date + element["time"] = time results_parsed.append(element) annotate_results(results_parsed)