Add tags for number of users and channels
This commit is contained in:
@@ -7,7 +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
|
||||
from core.lib.threshold import annotate_num_chans, annotate_num_users, annotate_online
|
||||
|
||||
client = initialise_opensearch()
|
||||
|
||||
@@ -42,14 +42,26 @@ def query_results(request, post_params, api=False):
|
||||
if "net" in x:
|
||||
nets.add(x["net"])
|
||||
|
||||
# Annotate the online attribute from Threshold
|
||||
for net in nets:
|
||||
# Annotate the online attribute from Threshold
|
||||
online_info = annotate_online(
|
||||
net, [x["nick"] for x in results_parsed if x["src"] == "irc"]
|
||||
)
|
||||
# Annotate the number of users in the channel
|
||||
num_users = annotate_num_users(
|
||||
net, [x["channel"] for x in results_parsed if x["src"] == "irc"]
|
||||
)
|
||||
# Annotate the number channels the user is on
|
||||
num_chans = annotate_num_chans(
|
||||
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"]]
|
||||
if item["channel"] in num_users:
|
||||
item["num_users"] = num_users[item["channel"]]
|
||||
if item["nick"] in num_chans:
|
||||
item["num_chans"] = num_chans[item["nick"]]
|
||||
|
||||
context = {
|
||||
"query": query,
|
||||
|
||||
Reference in New Issue
Block a user