Display 'Others' when max displayed reached

This commit is contained in:
Grégory Soutadé 2014-12-17 21:27:31 +01:00
parent f82e26e3bc
commit a74a6b8469
4 changed files with 37 additions and 0 deletions

View File

@ -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(['<b>%s</b>' % (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(['<b>%s</b>' % (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)

View File

@ -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)

View File

@ -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)

View File

@ -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)