Skip to content

Commit

Permalink
#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent 561ecc8 commit 9620eea
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ async def get_graph(graph_data):
''' Get the worker component and render it with the current configuration.'''
return await render_template('graph.html', graph_data=graph_data)

async def generate_graph_data(followers, followings):
nodes = [{'id': user['id'], 'username': user['username']} for user in followers + followings]
links = [{'source': follower['id'], 'target': following['id']} for follower in followers for following in followings]
logging.info(f"Generated graph data: {nodes}, {links}")
async def generate_graph_data(user, followers, followings):
# Add the authenticated user as the central node
nodes = [{'id': user['id'], 'username': user['username']}]
nodes += [{'id': u['id'], 'username': u['username']} for u in followers + followings]

# Create links from the central user to each follower and following
links = [{'source': user['id'], 'target': follower['id']} for follower in followers]
links += [{'source': user['id'], 'target': following['id']} for following in followings]

#logging.info(f"Generated graph data: {nodes}, {links}")
return {'nodes': nodes, 'links': links}

# Async setup function to load configs and create secrets
Expand Down

0 comments on commit 9620eea

Please sign in to comment.