Implement more UI elements
This commit is contained in:
@@ -7,6 +7,7 @@ from django.shortcuts import render
|
||||
from django.views import View
|
||||
|
||||
from core.lib.opensearch import initialise_opensearch, run_main_query
|
||||
from core.lib.threshold import annotate_online
|
||||
|
||||
client = initialise_opensearch()
|
||||
|
||||
@@ -26,7 +27,30 @@ def query_results(request, post_params, api=False):
|
||||
if "hits" in results.keys():
|
||||
if "hits" in results["hits"]:
|
||||
for item in results["hits"]["hits"]:
|
||||
results_parsed.append(item["_source"])
|
||||
element = item["_source"]
|
||||
element["id"] = item["_id"]
|
||||
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)
|
||||
# Figure out items with net (not discord)
|
||||
nets = set()
|
||||
for x in results_parsed:
|
||||
if "net" in x:
|
||||
nets.add(x["net"])
|
||||
|
||||
# Annotate the online attribute from Threshold
|
||||
for net in nets:
|
||||
online_info = annotate_online(
|
||||
net, [x["nick"] for x in results_parsed if x["src"] == "irc"]
|
||||
)
|
||||
for item in results_parsed:
|
||||
if item["nick"] in online_info:
|
||||
item["online"] = online_info[item["nick"]]
|
||||
|
||||
context = {
|
||||
"query": query,
|
||||
"results": results_parsed,
|
||||
|
||||
Reference in New Issue
Block a user