Compare commits

..

No commits in common. "53cb9a7f76c5f1db9ce00e5ea5f0cb77962cc78c" and "2153054cacde4543706daf47fd77a0adcea47524" have entirely different histories.

3 changed files with 12 additions and 21 deletions

View File

@ -108,7 +108,7 @@ class ElasticsearchBackend(StorageBackend):
extra_should.append({"match": {"nick": channel}}) extra_should.append({"match": {"nick": channel}})
else: else:
for ctype in types: for ctype in types:
extra_should.append({"match": {"mtype": ctype}}) extra_should.append({"equals": {"mtype": ctype}})
else: else:
for ctype in types: for ctype in types:
extra_should.append({"match": {"type": ctype}}) extra_should.append({"match": {"type": ctype}})

View File

@ -39,32 +39,23 @@ def annotate_results(results):
] ]
) )
) )
online_info = None online_info = annotate_online(net, nicks)
num_users = None
num_chans = None
if nicks:
online_info = annotate_online(net, nicks)
# Annotate the number of users in the channel # Annotate the number of users in the channel
if channels: num_users = annotate_num_users(net, channels)
num_users = annotate_num_users(net, channels)
# Annotate the number channels the user is on # Annotate the number channels the user is on
if nicks: num_chans = annotate_num_chans(net, nicks)
num_chans = annotate_num_chans(net, nicks)
for item in results: for item in results:
if "net" in item: if "net" in item:
if item["net"] == net: if item["net"] == net:
if "nick" in item: if "nick" in item:
if online_info: if item["nick"] in online_info:
if item["nick"] in online_info: item["online"] = online_info[item["nick"]]
item["online"] = online_info[item["nick"]]
if "channel" in item: if "channel" in item:
if num_users: if item["channel"] in num_users:
if item["channel"] in num_users: item["num_users"] = num_users[item["channel"]]
item["num_users"] = num_users[item["channel"]]
if "nick" in item: if "nick" in item:
if num_chans: if item["nick"] in num_chans:
if item["nick"] in num_chans: item["num_chans"] = num_chans[item["nick"]]
item["num_chans"] = num_chans[item["nick"]]
def parse_results(results, meta=None): def parse_results(results, meta=None):

View File

@ -4,7 +4,7 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
extra_should = [] extra_should = []
extra_should2 = [] extra_should2 = []
if num: if num:
extra_must.append({"match_phrase": {"num": num}}) extra_must.append({"equals": {"num": num}})
if net: if net:
extra_must.append({"match_phrase": {"net": net}}) extra_must.append({"match_phrase": {"net": net}})
if channel: if channel:
@ -52,7 +52,7 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
extra_should.append({"match": {"nick": channel}}) extra_should.append({"match": {"nick": channel}})
else: else:
for ctype in types: for ctype in types:
extra_should.append({"match": {"mtype": ctype}}) extra_should.append({"equals": {"mtype": ctype}})
else: else:
for ctype in types: for ctype in types:
extra_should.append({"match": {"type": ctype}}) extra_should.append({"match": {"type": ctype}})