WebStats: fix links algorithm
parent
154a0e2654
commit
e1f83797e5
|
@ -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()
|
||||
|
|
|
@ -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])):
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue