From 4e99b774925001119577b2738d6e2a816efe5b8b Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Wed, 4 Mar 2026 20:03:48 +0000 Subject: [PATCH] fix(db): missing post ID in db schema Caused surprisingly little errors. It only broke the interaction graph. --- server/analysis/interactional.py | 4 ++-- server/core/datasets.py | 4 +++- server/db/schema.sql | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/analysis/interactional.py b/server/analysis/interactional.py index 5c8ac3d..864980d 100644 --- a/server/analysis/interactional.py +++ b/server/analysis/interactional.py @@ -127,8 +127,8 @@ class InteractionAnalysis: def interaction_graph(self, df: pd.DataFrame): interactions = {a: {} for a in df["author"].dropna().unique()} - # reply_to refers to the comment id, this allows us to map comment ids to usernames - id_to_author = df.set_index("id")["author"].to_dict() + # reply_to refers to the comment id, this allows us to map comment/post ids to usernames + id_to_author = df.set_index("post_id")["author"].to_dict() for _, row in df.iterrows(): a = row["author"] diff --git a/server/core/datasets.py b/server/core/datasets.py index 2f0e35f..e7ee717 100644 --- a/server/core/datasets.py +++ b/server/core/datasets.py @@ -52,6 +52,7 @@ class DatasetManager: query = """ INSERT INTO events ( dataset_id, + post_id, type, parent_id, author, @@ -78,13 +79,14 @@ class DatasetManager: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, - %s + %s, %s ) """ values = [ ( dataset_id, + row["id"], row["type"], row["parent_id"], row["author"], diff --git a/server/db/schema.sql b/server/db/schema.sql index 5379a95..051a396 100644 --- a/server/db/schema.sql +++ b/server/db/schema.sql @@ -30,6 +30,8 @@ CREATE TABLE events ( /* Required Fields */ id SERIAL PRIMARY KEY, dataset_id INTEGER NOT NULL, + + post_id VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, author VARCHAR(255) NOT NULL,