From a74a6b8469e399d33838a40fb105e619b2f7318e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 17 Dec 2014 21:27:31 +0100 Subject: [PATCH] Display 'Others' when max displayed reached --- plugins/display/referers.py | 18 ++++++++++++++++++ plugins/display/top_downloads.py | 6 ++++++ plugins/display/top_hits.py | 7 +++++++ plugins/display/top_pages.py | 6 ++++++ 4 files changed, 37 insertions(+) diff --git a/plugins/display/referers.py b/plugins/display/referers.py index db56caf..5676053 100644 --- a/plugins/display/referers.py +++ b/plugins/display/referers.py @@ -83,6 +83,12 @@ class IWLADisplayReferers(IPlugin): total_search[1] += search_engine_referers[r]['pages'] total_search[2] += search_engine_referers[r]['hits'] table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') total_external = [0]*3 table.appendRow(['%s' % (self.iwla._(u'External URL')), '', '']) @@ -92,6 +98,12 @@ class IWLADisplayReferers(IPlugin): total_external[1] += referers[r]['pages'] total_external[2] += referers[r]['hits'] table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') total_robot = [0]*3 table.appendRow(['%s' % (self.iwla._(u'External URL (robot)')), '', '']) @@ -101,6 +113,12 @@ class IWLADisplayReferers(IPlugin): total_robot[1] += robots_referers[r]['pages'] total_robot[2] += robots_referers[r]['hits'] table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') page.appendBlock(table) diff --git a/plugins/display/top_downloads.py b/plugins/display/top_downloads.py index 790dc38..140e508 100644 --- a/plugins/display/top_downloads.py +++ b/plugins/display/top_downloads.py @@ -56,6 +56,12 @@ class IWLADisplayTopDownloads(IPlugin): for (uri, entrance) in new_list: table.appendRow([generateHTMLLink(uri), entrance]) total_entrance[1] += entrance + if self.max_downloads: + others = 0 + for (uri, entrance) in top_downloads[self.max_downloads:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') page.appendBlock(table) display.addPage(page) diff --git a/plugins/display/top_hits.py b/plugins/display/top_hits.py index 73d29ee..cb0be25 100644 --- a/plugins/display/top_hits.py +++ b/plugins/display/top_hits.py @@ -55,6 +55,13 @@ class IWLADisplayTopHits(IPlugin): for (uri, entrance) in new_list: table.appendRow([generateHTMLLink(uri), entrance]) total_hits[1] += entrance + if self.max_hits: + others = 0 + for (uri, entrance) in top_hits[self.max_hits:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + page.appendBlock(table) display.addPage(page) diff --git a/plugins/display/top_pages.py b/plugins/display/top_pages.py index f0d8fd6..6ae97d8 100644 --- a/plugins/display/top_pages.py +++ b/plugins/display/top_pages.py @@ -55,6 +55,12 @@ class IWLADisplayTopPages(IPlugin): for (uri, entrance) in new_list: table.appendRow([generateHTMLLink(uri), entrance]) total_hits[1] += entrance + if self.max_pages: + others = 0 + for (uri, entrance) in top_pages[self.max_pages:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') page.appendBlock(table) display.addPage(page)