From 9620eea29171314300006c4370fa535772d3a6ed Mon Sep 17 00:00:00 2001 From: Scobiform Date: Wed, 17 Apr 2024 18:31:17 +0200 Subject: [PATCH] #1 --- start.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/start.py b/start.py index 0c64795..f68aabd 100644 --- a/start.py +++ b/start.py @@ -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