WebStats: fix links algorithm

master
Valentin Lorentz 2011-03-11 18:58:57 +01:00
parent 154a0e2654
commit e1f83797e5
2 changed files with 13 additions and 5 deletions

View File

@ -273,6 +273,8 @@ class WebStatsDB:
for chan, nicks in tmp_links_cache.items():
for nick, tos in nicks.items(): # Yes, tos is the plural for to
for to, count in tos.items():
if to not in nicks:
continue
cursor.execute('INSERT INTO links_cache VALUES(?,?,?,?)',
(chan, nick, to, count))
cursor.close()

View File

@ -40,13 +40,19 @@ def get(useSkeleton, channel, db, urlLevel, page, orderBy=None):
graph = pygraphviz.AGraph(strict=False, directed=True)
insertedNicks = []
for item in items:
for i in (1, 2):
if item[i] not in insertedNicks:
graph.add_node(item[i])
if item[0] not in insertedNicks:
try:
graph.add_node(item[0])
insertedNicks.append(item[0])
except: # Probably unicode issue
pass
for foo in range(0, int(item[2])):
graph.add_edge(item[0], item[1])
try:
graph.add_edge(item[0], item[1])
except:
pass
buffer_ = StringIO()
graph.draw(buffer_, prog='fdp', format='png')
graph.draw(buffer_, prog='circo', format='png')
buffer_.seek(0)
output = buffer_.read()