Fix insights

This commit is contained in:
2023-01-14 16:36:00 +00:00
parent dbf581245b
commit 9ee9c7abde
10 changed files with 126 additions and 111 deletions

View File

@@ -3,7 +3,7 @@ from math import ceil
from django.conf import settings
from numpy import array_split
from core.db.elastic import client, run_main_query
from core.db.storage import db
def construct_query(net, nicks):
@@ -43,27 +43,14 @@ def get_meta(request, net, nicks, iter=True):
break
meta_tmp = []
query = construct_query(net, nicks_chunked)
results = run_main_query(
client,
results = db.query(
request.user,
query,
custom_query=True,
index=settings.ELASTICSEARCH_INDEX_META,
index=settings.INDEX_META,
)
if "hits" in results.keys():
if "hits" in results["hits"]:
for item in results["hits"]["hits"]:
element = item["_source"]
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
meta_tmp.append(element)
if "object_list" in results.keys():
for element in results["object_list"]:
meta_tmp.append(element)
for x in meta_tmp:
if x not in meta:
meta.append(x)