Implement getting LIST information from API
This commit is contained in:
@@ -347,21 +347,22 @@ def _initialList(net, num, listinfo, chanlimit):
|
||||
relay = ceil(listlength / chanlimit)
|
||||
|
||||
abase = "analytics.list.%s" % net
|
||||
main.g.delete(abase)
|
||||
p = main.g.pipeline()
|
||||
|
||||
# See docstring for meanings
|
||||
p.hset(abase, "mean", mean)
|
||||
p.hset(abase, "total", listlength)
|
||||
p.hset(abase, "sigtotal", siglength)
|
||||
p.hset(abase, "insigtotal", insiglength)
|
||||
p.hset(abase, "sigperc", round(siglength / listlength * 100, 2))
|
||||
p.hset(abase, "insigperc", round(insiglength / listlength * 100, 2))
|
||||
p.hset(abase, "cumul", cumul)
|
||||
p.hset(abase, "sigcumul", sigcumul)
|
||||
p.hset(abase, "insigcumul", insigcumul)
|
||||
p.hset(abase, "relay", relay)
|
||||
p.hset(abase, "sigrelay", sigrelay)
|
||||
p.hset(abase, "insigrelay", ceil(insiglength / chanlimit))
|
||||
p.hset(abase, "total_chans", listlength)
|
||||
p.hset(abase, "big_chans", siglength)
|
||||
p.hset(abase, "small_chans", insiglength)
|
||||
p.hset(abase, "big_chan_perc", round(siglength / listlength * 100, 2))
|
||||
p.hset(abase, "small_chan_perc", round(insiglength / listlength * 100, 2))
|
||||
p.hset(abase, "total_cumul_mem", cumul)
|
||||
p.hset(abase, "big_chan_cumul_mem", sigcumul)
|
||||
p.hset(abase, "small_chan_cumul_mem", insigcumul)
|
||||
p.hset(abase, "relays_for_all_chans", relay)
|
||||
p.hset(abase, "relays_for_big_chans", sigrelay)
|
||||
p.hset(abase, "relays_for_small_chans", ceil(insiglength / chanlimit))
|
||||
debug(
|
||||
(
|
||||
f"_initialList() net:{net} num:{num} listlength:{listlength} "
|
||||
@@ -383,6 +384,26 @@ def _initialList(net, num, listinfo, chanlimit):
|
||||
|
||||
# return (listinfo, mean, sigrelay, relay)
|
||||
|
||||
def convert(data):
|
||||
"""
|
||||
Recursively convert a dictionary.
|
||||
"""
|
||||
if isinstance(data, bytes):
|
||||
return data.decode("ascii")
|
||||
if isinstance(data, dict):
|
||||
return dict(map(convert, data.items()))
|
||||
if isinstance(data, tuple):
|
||||
return map(convert, data)
|
||||
if isinstance(data, list):
|
||||
return list(map(convert, data))
|
||||
return data
|
||||
|
||||
|
||||
def getListInfo(net):
|
||||
abase = f"analytics.list.{net}"
|
||||
info = main.g.hgetall(abase)
|
||||
return convert(info)
|
||||
|
||||
|
||||
def initialList(net, num, listinfo, chanlimit):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user