From 4df8ae273e53f2c5f2495a8833315aabb843cf1f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 2 Jan 2026 01:24:58 +0000 Subject: [PATCH] Add edge_type support to graph table and API - New column edge_type varchar(30) in graph table - GET /api/graph/edges returns edge_type (defaults to "db" if null) - POST /api/graph/edges accepts type parameter and stores as edge_type Types: mirror, sequence, composition, dependency, maturity, manual, db --- app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index fb39206..45614b1 100644 --- a/app.py +++ b/app.py @@ -240,8 +240,8 @@ if __name__ == "__main__": def api_graph_edges(): conn = get_db() cur = conn.cursor() - cur.execute("SELECT id, h_a, h_b, weight FROM graph ORDER BY weight DESC") - edges = [{"id": r[0], "source_h": r[1], "target_h": r[2], "weight": r[3], "type": "db"} for r in cur.fetchall()] + cur.execute("SELECT id, h_a, h_b, weight, edge_type FROM graph ORDER BY weight DESC") + edges = [{"id": r[0], "source_h": r[1], "target_h": r[2], "weight": r[3], "type": r[4] or "db"} for r in cur.fetchall()] cur.close() conn.close() return jsonify({"count": len(edges), "edges": edges}) @@ -259,7 +259,7 @@ def api_graph_edges_create(): conn = get_db() cur = conn.cursor() - cur.execute("INSERT INTO graph (h_a, h_b, weight) VALUES (%s, %s, %s) RETURNING id", (source_h, target_h, weight)) + cur.execute("INSERT INTO graph (h_a, h_b, weight, edge_type) VALUES (%s, %s, %s, %s) RETURNING id", (source_h, target_h, weight, edge_type)) new_id = cur.fetchone()[0] conn.commit() cur.close()