Implement indexing into Apache Druid #1
59
api/views.py
59
api/views.py
|
@ -132,7 +132,7 @@ class API(object):
|
||||||
if "query" not in data:
|
if "query" not in data:
|
||||||
return "No users provided"
|
return "No users provided"
|
||||||
if not data["query"]:
|
if not data["query"]:
|
||||||
warn(f"No chans provided: for online {data}")
|
warn(f"No chans provided: for num_users {data}")
|
||||||
return dumps({})
|
return dumps({})
|
||||||
net = data["net"]
|
net = data["net"]
|
||||||
results = userinfo.getUserNum(net, data["query"])
|
results = userinfo.getUserNum(net, data["query"])
|
||||||
|
@ -151,7 +151,7 @@ class API(object):
|
||||||
if "query" not in data:
|
if "query" not in data:
|
||||||
return "No users provided"
|
return "No users provided"
|
||||||
if not data["query"]:
|
if not data["query"]:
|
||||||
warn(f"No users provided: for online {data}")
|
warn(f"No users provided: for num_chans {data}")
|
||||||
return dumps({})
|
return dumps({})
|
||||||
net = data["net"]
|
net = data["net"]
|
||||||
results = userinfo.getChanNum(net, data["query"])
|
results = userinfo.getChanNum(net, data["query"])
|
||||||
|
@ -190,3 +190,58 @@ class API(object):
|
||||||
"records": userinfo.getNumWhoEntries(net),
|
"records": userinfo.getNumWhoEntries(net),
|
||||||
}
|
}
|
||||||
return dumps(networks)
|
return dumps(networks)
|
||||||
|
|
||||||
|
@app.route("/irc/network/<net>/", methods=["POST"])
|
||||||
|
@login_required
|
||||||
|
def irc_network(self, request, net):
|
||||||
|
if net not in main.network.keys():
|
||||||
|
return dumps(False)
|
||||||
|
inst = main.network[net]
|
||||||
|
network = {}
|
||||||
|
network["net"] = inst.net
|
||||||
|
network["auth"] = inst.auth
|
||||||
|
network["host"] = inst.host
|
||||||
|
network["last"] = inst.last
|
||||||
|
network["port"] = inst.port
|
||||||
|
network["security"] = inst.security
|
||||||
|
network["relays"] = len(inst.relays)
|
||||||
|
network["channels"] = userinfo.getTotalChanNum(net)
|
||||||
|
network["records"] = userinfo.getNumWhoEntries(net)
|
||||||
|
return dumps(network)
|
||||||
|
|
||||||
|
@app.route("/irc/network/<net>/relays/", methods=["POST"])
|
||||||
|
@login_required
|
||||||
|
def irc_network_relays(self, request, net):
|
||||||
|
if net not in main.network.keys():
|
||||||
|
return dumps(False)
|
||||||
|
relays_inst = main.network[net].relays
|
||||||
|
relays = []
|
||||||
|
for num in relays_inst.keys():
|
||||||
|
to_append = relays_inst[num]
|
||||||
|
name = f"{net}{num}"
|
||||||
|
if name in main.IRCPool.keys():
|
||||||
|
to_append["chans"] = len(main.IRCPool[name].channels)
|
||||||
|
to_append["nick"] = main.IRCPool[name].nickname
|
||||||
|
else:
|
||||||
|
to_append["chans"] = 0
|
||||||
|
to_append["nick"] = None
|
||||||
|
relays.append(to_append)
|
||||||
|
|
||||||
|
return dumps({"relays": relays})
|
||||||
|
|
||||||
|
@app.route("/irc/network/<net>/channels/", methods=["POST"])
|
||||||
|
@login_required
|
||||||
|
def irc_network_channels(self, request, net):
|
||||||
|
if net not in main.network.keys():
|
||||||
|
return dumps(False)
|
||||||
|
relays_inst = main.network[net].relays
|
||||||
|
channels = {}
|
||||||
|
for num in relays_inst.keys():
|
||||||
|
name = f"{net}{num}"
|
||||||
|
if name in main.IRCPool.keys():
|
||||||
|
net_chans = main.IRCPool[name].channels
|
||||||
|
channels_annotated = userinfo.getUserNum(net, net_chans)
|
||||||
|
for channel in net_chans:
|
||||||
|
channels[channel] = channels_annotated[channel]
|
||||||
|
|
||||||
|
return dumps({"channels": channels})
|
||||||
|
|
Loading…
Reference in New Issue