Implement storing analytics on a LIST response
This commit is contained in:
@@ -1 +1,45 @@
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
|
||||
# make this into a threaded function
|
||||
def initialList(net, num, listinfo, chanLimit):
|
||||
#listinfo = sorted(listinfo, key=lambda x: xdd[0])
|
||||
listLength = len(listinfo)
|
||||
cumul = 0
|
||||
try:
|
||||
cumul += sum(int(i[1]) for i in listinfo)
|
||||
except TypeError:
|
||||
warn("Bad LIST data received from %s - %i" % (net, num))
|
||||
return
|
||||
mean = cumul/listLength
|
||||
sigLength = 0
|
||||
insigLength = 0
|
||||
sigCumul = 0
|
||||
insigCumul = 0
|
||||
for i in listinfo:
|
||||
if int(i[1]) > mean:
|
||||
sigLength += 1
|
||||
sigCumul += int(i[1])
|
||||
elif int(i[1]) < mean:
|
||||
insigLength += 1
|
||||
insigCumul += int(i[1])
|
||||
|
||||
if not net in main.network.keys():
|
||||
warn("Cannot write list info - no network entry for %s" % net)
|
||||
return
|
||||
main.network[net].list["mean"] = mean
|
||||
main.network[net].list["total"] = listLength
|
||||
main.network[net].list["sigtotal"] = sigLength
|
||||
main.network[net].list["insigtotal"] = insigLength
|
||||
main.network[net].list["sigperc"] = sigLength/listLength*100
|
||||
main.network[net].list["insigperc"] = insigLength/listLength*100
|
||||
main.network[net].list["cumul"] = cumul
|
||||
main.network[net].list["sigcumul"] = sigCumul
|
||||
main.network[net].list["insigcumul"] = insigCumul
|
||||
main.network[net].list["relay"] = listLength/chanLimit
|
||||
main.network[net].list["sigrelay"] = sigLength/chanLimit
|
||||
main.network[net].list["insigrelay"] = insigLength/chanLimit
|
||||
|
||||
# Rounding
|
||||
main.network[net].list = {x: round(y, 4) for x, y in main.network[net].list.items()}
|
||||
main.saveConf("network")
|
||||
|
||||
@@ -19,6 +19,7 @@ class Network:
|
||||
self.last = 0
|
||||
self.relays = {}
|
||||
self.aliases = {}
|
||||
self.list = {}
|
||||
|
||||
def add_relay(self, num=None):
|
||||
if not num:
|
||||
|
||||
Reference in New Issue
Block a user