Fix context menu
This commit is contained in:
@@ -19,6 +19,64 @@ class DruidBackend(StorageBackend):
|
||||
# self.client = PyDruid("http://broker:8082", "druid/v2")
|
||||
pass # we use requests
|
||||
|
||||
def construct_context_query(
|
||||
self, index, net, channel, src, num, size, type=None, nicks=None
|
||||
):
|
||||
search_query = self.construct_query(None, size, index, blank=True)
|
||||
extra_must = []
|
||||
extra_should = []
|
||||
extra_should2 = []
|
||||
if num:
|
||||
extra_must.append({"num": num})
|
||||
if net:
|
||||
extra_must.append({"net": net})
|
||||
if channel:
|
||||
extra_must.append({"channel": channel})
|
||||
if nicks:
|
||||
for nick in nicks:
|
||||
extra_should2.append({"nick": nick})
|
||||
types = ["msg", "notice", "action", "kick", "topic", "mode"]
|
||||
|
||||
if index == "internal":
|
||||
if channel == "*status" or type == "znc":
|
||||
if {"channel": channel} in extra_must:
|
||||
extra_must.remove({"channel": channel})
|
||||
extra_should2 = []
|
||||
# Type is one of msg or notice
|
||||
# extra_should.append({"match": {"mtype": "msg"}})
|
||||
# extra_should.append({"match": {"mtype": "notice"}})
|
||||
extra_should.append({"type": "znc"})
|
||||
extra_should.append({"type": "self"})
|
||||
|
||||
extra_should2.append({"type": "znc"})
|
||||
extra_should2.append({"nick": channel})
|
||||
elif type == "auth":
|
||||
if {"match": {"channel": channel}} in extra_must:
|
||||
extra_must.remove({"channel": channel})
|
||||
extra_should2 = []
|
||||
extra_should2.append({"nick": channel})
|
||||
# extra_should2.append({"match": {"mtype": "msg"}})
|
||||
# extra_should2.append({"match": {"mtype": "notice"}})
|
||||
|
||||
extra_should.append({"type": "query"})
|
||||
extra_should2.append({"type": "self"})
|
||||
extra_should.append({"nick": channel})
|
||||
else:
|
||||
for ctype in types:
|
||||
extra_should.append({"mtype": ctype})
|
||||
else:
|
||||
for ctype in types:
|
||||
extra_should.append({"type": ctype})
|
||||
|
||||
if extra_must:
|
||||
self.add_type("and", search_query, extra_must)
|
||||
|
||||
if extra_should:
|
||||
self.add_type("or", search_query, extra_should)
|
||||
if extra_should2:
|
||||
self.add_type("or", search_query, extra_should2)
|
||||
return search_query
|
||||
|
||||
def construct_query(self, query, size, index, blank=False):
|
||||
search_query = {
|
||||
"limit": size,
|
||||
|
||||
Reference in New Issue
Block a user