iwla/plugins/post_analysis/top_visitors.py

16 lines
551 B
Python
Raw Normal View History

from iwla import IWLA
2014-11-24 17:13:59 +01:00
from iplugin import IPlugin
class IWLAPostAnalysisTopVisitors(IPlugin):
2014-11-24 21:42:57 +01:00
def __init__(self, iwla):
super(IWLAPostAnalysisTopVisitors, self).__init__(iwla)
2014-11-24 17:13:59 +01:00
self.API_VERSION = 1
def hook(self):
hits = self.iwla.getValidVisitors()
stats = self.iwla.getMonthStats()
2014-11-26 16:17:16 +01:00
top_bandwidth = [(k,hits[k]['bandwidth']) for k in hits.keys()]
2014-11-24 17:13:59 +01:00
top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True)
stats['top_visitors'] = [hits[h[0]] for h in top_bandwidth[:10]]