Add Others field in index

This commit is contained in:
Grégory Soutadé 2014-12-05 16:03:09 +01:00
parent 4cb2736e22
commit fd858034fb
7 changed files with 79 additions and 4 deletions

View File

@ -66,6 +66,12 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock):
self.rows.append(listToStr(row)) self.rows.append(listToStr(row))
self.rows_cssclasses.append([u''] * len(row)) self.rows_cssclasses.append([u''] * len(row))
def getNbRows(self):
return len(self.rows)
def getNbCols(self):
return len(self.cols)
def getCellValue(self, row, col): def getCellValue(self, row, col):
if row < 0 or col < 0 or\ if row < 0 or col < 0 or\
row >= len(self.rows) or col >= len(self.cols): row >= len(self.rows) or col >= len(self.cols):

View File

@ -42,19 +42,28 @@ class IWLADisplayReferers(IPlugin):
table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits']) table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits'])
table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_page', 'iwla_hit'])
total_search = [0]*3
table.appendRow(['<b>Search Engine</b>', '', '']) table.appendRow(['<b>Search Engine</b>', '', ''])
for r,_ in top_search_engine_referers: for r,_ in top_search_engine_referers:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
total_search[1] += search_engine_referers[r]['pages']
total_search[2] += search_engine_referers[r]['hits']
table.appendRow(row) table.appendRow(row)
total_external = [0]*3
table.appendRow(['<b>External URL</b>', '', '']) table.appendRow(['<b>External URL</b>', '', ''])
for r,_ in top_referers: for r,_ in top_referers:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']] row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
total_external[1] += referers[r]['pages']
total_external[2] += referers[r]['hits']
table.appendRow(row) table.appendRow(row)
total_robot = [0]*3
table.appendRow(['<b>External URL (robot)</b>', '', '']) table.appendRow(['<b>External URL (robot)</b>', '', ''])
for r,_ in top_robots_referers: for r,_ in top_robots_referers:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']] row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
total_robot[1] += robots_referers[r]['pages']
total_robot[2] += robots_referers[r]['hits']
table.appendRow(row) table.appendRow(row)
page.appendBlock(table) page.appendBlock(table)
@ -73,17 +82,35 @@ class IWLADisplayReferers(IPlugin):
table.appendRow(['<b>Search Engine</b>', '', '']) table.appendRow(['<b>Search Engine</b>', '', ''])
for r,_ in top_search_engine_referers[:10]: for r,_ in top_search_engine_referers[:10]:
row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']]
total_search[1] -= search_engine_referers[r]['pages']
total_search[2] -= search_engine_referers[r]['hits']
table.appendRow(row) table.appendRow(row)
if total_search[1] or total_search[2]:
total_search[0] = 'Others'
table.appendRow(total_search)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['<b>External URL</b>', '', '']) table.appendRow(['<b>External URL</b>', '', ''])
for r,_ in top_referers[:10]: for r,_ in top_referers[:10]:
row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']] row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']]
total_external[1] -= referers[r]['pages']
total_external[2] -= referers[r]['hits']
table.appendRow(row) table.appendRow(row)
if total_external[1] or total_external[2]:
total_external[0] = 'Others'
table.appendRow(total_external)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
table.appendRow(['<b>External URL (robot)</b>', '', '']) table.appendRow(['<b>External URL (robot)</b>', '', ''])
for r,_ in top_robots_referers[:10]: for r,_ in top_robots_referers[:10]:
row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']] row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']]
total_robot[1] -= robots_referers[r]['pages']
total_robot[2] -= robots_referers[r]['hits']
table.appendRow(row) table.appendRow(row)
if total_robot[1] or total_robot[2]:
total_robot[0] = 'Others'
table.appendRow(total_robot)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)
@ -93,11 +120,13 @@ class IWLADisplayReferers(IPlugin):
filename = 'key_phrases.html' filename = 'key_phrases.html'
path = self.iwla.getCurDisplayPath(filename) path = self.iwla.getCurDisplayPath(filename)
total_search = [0]*2
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', [])) page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search']) table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search'])
table.setColsCSSClass(['', 'iwla_search']) table.setColsCSSClass(['', 'iwla_search'])
for phrase in top_key_phrases: for phrase in top_key_phrases:
table.appendRow([phrase[0], phrase[1]]) table.appendRow([phrase[0], phrase[1]])
total_search[1] += phrase[1]
page.appendBlock(table) page.appendBlock(table)
display.addPage(page) display.addPage(page)
@ -110,4 +139,9 @@ class IWLADisplayReferers(IPlugin):
table.setColsCSSClass(['', 'iwla_search']) table.setColsCSSClass(['', 'iwla_search'])
for phrase in top_key_phrases[:10]: for phrase in top_key_phrases[:10]:
table.appendRow([phrase[0], phrase[1]]) table.appendRow([phrase[0], phrase[1]])
total_search[1] -= phrase[1]
if total_search[1]:
total_search[0] = 'Others'
table.appendRow(total_search)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)

View File

@ -22,8 +22,11 @@ class IWLADisplayTopDownloads(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', [])) page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit']) table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
total_entrance = [0]*2
for (uri, entrance) in top_downloads: for (uri, entrance) in top_downloads:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_entrance[1] += entrance
page.appendBlock(table) page.appendBlock(table)
self.iwla.getDisplay().addPage(page) self.iwla.getDisplay().addPage(page)
@ -38,4 +41,9 @@ class IWLADisplayTopDownloads(IPlugin):
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_downloads[:10]: for (uri, entrance) in top_downloads[:10]:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_entrance[1] -= entrance
if total_entrance[1]:
total_entrance[0] = 'Others'
table.appendRow(total_entrance)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)

View File

@ -22,8 +22,10 @@ class IWLADisplayTopHits(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', [])) page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance']) table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
total_hits = [0]*2
for (uri, entrance) in top_hits: for (uri, entrance) in top_hits:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] += entrance
page.appendBlock(table) page.appendBlock(table)
self.iwla.getDisplay().addPage(page) self.iwla.getDisplay().addPage(page)
@ -38,4 +40,9 @@ class IWLADisplayTopHits(IPlugin):
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_hits[:10]: for (uri, entrance) in top_hits[:10]:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] -= entrance
if total_hits[1]:
total_hits[0] = 'Others'
table.appendRow(total_hits)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)

View File

@ -22,8 +22,10 @@ class IWLADisplayTopPages(IPlugin):
page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', [])) page = DisplayHTMLPage(title, path, self.iwla.getConfValue('css_path', []))
table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance']) table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance'])
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
total_hits = [0]*2
for (uri, entrance) in top_pages: for (uri, entrance) in top_pages:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] += entrance
page.appendBlock(table) page.appendBlock(table)
self.iwla.getDisplay().addPage(page) self.iwla.getDisplay().addPage(page)
@ -38,4 +40,9 @@ class IWLADisplayTopPages(IPlugin):
table.setColsCSSClass(['', 'iwla_hit']) table.setColsCSSClass(['', 'iwla_hit'])
for (uri, entrance) in top_pages[:10]: for (uri, entrance) in top_pages[:10]:
table.appendRow([generateHTMLLink(uri), entrance]) table.appendRow([generateHTMLLink(uri), entrance])
total_hits[1] -= entrance
if total_hits[1]:
total_hits[0] = 'Others'
table.appendRow(total_hits)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)

View File

@ -11,11 +11,15 @@ class IWLADisplayTopVisitors(IPlugin):
def hook(self): def hook(self):
hits = self.iwla.getValidVisitors() hits = self.iwla.getValidVisitors()
count_hit_only = self.iwla.getConfValue('count_hit_only_visitors', False)
display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False) display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False)
top_bandwidth = [(k,v['bandwidth']) for (k,v) in hits.items() \ total = [0]*5
if count_hit_only or v['viewed_pages']] for super_hit in hits.values():
total[1] += super_hit['viewed_pages']
total[2] += super_hit['viewed_hits']
total[3] += super_hit['bandwidth']
top_bandwidth = [(k,v['bandwidth']) for (k,v) in hits.items()]
top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True) top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True)
top_visitors = [hits[h[0]] for h in top_bandwidth[:10]] top_visitors = [hits[h[0]] for h in top_bandwidth[:10]]
@ -35,5 +39,14 @@ class IWLADisplayTopVisitors(IPlugin):
bytesToStr(super_hit['bandwidth']), bytesToStr(super_hit['bandwidth']),
time.asctime(super_hit['last_access']) time.asctime(super_hit['last_access'])
] ]
total[1] -= super_hit['viewed_pages']
total[2] -= super_hit['viewed_hits']
total[3] -= super_hit['bandwidth']
table.appendRow(row) table.appendRow(row)
if total[1] or total[2] or total[3]:
total[0] = 'Others'
total[3] = bytesToStr(total[3])
total[4] = ''
table.appendRow(total)
table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others')
index.appendBlock(table) index.appendBlock(table)

View File

@ -68,7 +68,7 @@ td:first-child
.iwla_search { background : #F4F090; } .iwla_search { background : #F4F090; }
.iwla_weekend { background : #ECECEC; } .iwla_weekend { background : #ECECEC; }
.iwla_curday { font-weight: bold; } .iwla_curday { font-weight: bold; }
.iwla_others { color: #668; }
.iwla_graph_table .iwla_graph_table
{ {
margin-left:auto; margin-left:auto;