From 65b5eeae88e31d60e1c2950fb4efe2ab19a78abf Mon Sep 17 00:00:00 2001 From: Pavlo Paliychuk Date: Tue, 8 Apr 2025 14:48:36 -0400 Subject: [PATCH] Refactor ORDER BY clauses in edges and nodes to use created_at instead of uuid for better chronological sorting (#322) * Refactor ORDER BY clauses in edges and nodes to use created_at instead of uuid for better chronological sorting * Update ORDER BY clauses in edges and nodes to include uuid for improved sorting consistency --- graphiti_core/edges.py | 6 +++--- graphiti_core/nodes.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/graphiti_core/edges.py b/graphiti_core/edges.py index 622c2631..d1df1ad3 100644 --- a/graphiti_core/edges.py +++ b/graphiti_core/edges.py @@ -161,7 +161,7 @@ class EpisodicEdge(Edge): n.uuid AS source_node_uuid, m.uuid AS target_node_uuid, e.created_at AS created_at - ORDER BY e.uuid DESC + ORDER BY e.created_at, e.uuid DESC """ + limit_query, group_ids=group_ids, @@ -322,7 +322,7 @@ class EntityEdge(Edge): e.expired_at AS expired_at, e.valid_at AS valid_at, e.invalid_at AS invalid_at - ORDER BY e.uuid DESC + ORDER BY e.created_at, e.uuid DESC """ + limit_query, group_ids=group_ids, @@ -448,7 +448,7 @@ class CommunityEdge(Edge): n.uuid AS source_node_uuid, m.uuid AS target_node_uuid, e.created_at AS created_at - ORDER BY e.uuid DESC + ORDER BY e.created_at, e.uuid DESC """ + limit_query, group_ids=group_ids, diff --git a/graphiti_core/nodes.py b/graphiti_core/nodes.py index 3341f857..807c2271 100644 --- a/graphiti_core/nodes.py +++ b/graphiti_core/nodes.py @@ -237,7 +237,7 @@ class EpisodicNode(Node): e.source_description AS source_description, e.source AS source, e.entity_edges AS entity_edges - ORDER BY e.uuid DESC + ORDER BY e.created_at, e.uuid DESC """ + limit_query, group_ids=group_ids, @@ -368,7 +368,7 @@ class EntityNode(Node): n.summary AS summary, labels(n) AS labels, properties(n) AS attributes - ORDER BY n.uuid DESC + ORDER BY n.created_at DESC """ + limit_query, group_ids=group_ids, @@ -483,7 +483,7 @@ class CommunityNode(Node): n.group_id AS group_id, n.created_at AS created_at, n.summary AS summary - ORDER BY n.uuid DESC + ORDER BY n.created_at DESC """ + limit_query, group_ids=group_ids,