Spaces:
Sleeping
Sleeping
Update graph_manager.py
Browse files- graph_manager.py +22 -7
graph_manager.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# graph_manager.py - Version Graph Management
|
| 2 |
import networkx as nx
|
| 3 |
from typing import List, Dict, Optional, Set
|
| 4 |
import json
|
|
@@ -88,13 +88,22 @@ class GraphManager:
|
|
| 88 |
return {}
|
| 89 |
|
| 90 |
def get_changes_between_versions(self, document_name: str,
|
| 91 |
-
version1: str, version2: str
|
| 92 |
-
|
|
|
|
| 93 |
content1 = self.version_content.get((document_name, version1), "")
|
| 94 |
content2 = self.version_content.get((document_name, version2), "")
|
| 95 |
|
| 96 |
if not content1 or not content2:
|
| 97 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
# Compute diff
|
| 100 |
lines1 = content1.split('\n')
|
|
@@ -114,10 +123,16 @@ class GraphManager:
|
|
| 114 |
elif line.startswith('?'):
|
| 115 |
modifications.append(line[1:])
|
| 116 |
|
|
|
|
| 117 |
return {
|
| 118 |
-
'additions': additions[:
|
| 119 |
-
'deletions': deletions[:
|
| 120 |
-
'modifications': modifications[:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
def query_version_graph(self, query: str) -> List[Dict]:
|
|
|
|
| 1 |
+
# graph_manager.py - Version Graph Management (FIXED CHANGE DETECTION)
|
| 2 |
import networkx as nx
|
| 3 |
from typing import List, Dict, Optional, Set
|
| 4 |
import json
|
|
|
|
| 88 |
return {}
|
| 89 |
|
| 90 |
def get_changes_between_versions(self, document_name: str,
|
| 91 |
+
version1: str, version2: str,
|
| 92 |
+
max_display: int = 100) -> Dict:
|
| 93 |
+
"""Compute changes between two versions - FIXED TO SHOW ALL CHANGES"""
|
| 94 |
content1 = self.version_content.get((document_name, version1), "")
|
| 95 |
content2 = self.version_content.get((document_name, version2), "")
|
| 96 |
|
| 97 |
if not content1 or not content2:
|
| 98 |
+
return {
|
| 99 |
+
'additions': [],
|
| 100 |
+
'deletions': [],
|
| 101 |
+
'modifications': [],
|
| 102 |
+
'total_additions': 0,
|
| 103 |
+
'total_deletions': 0,
|
| 104 |
+
'total_modifications': 0,
|
| 105 |
+
'showing_limit': 0
|
| 106 |
+
}
|
| 107 |
|
| 108 |
# Compute diff
|
| 109 |
lines1 = content1.split('\n')
|
|
|
|
| 123 |
elif line.startswith('?'):
|
| 124 |
modifications.append(line[1:])
|
| 125 |
|
| 126 |
+
# FIXED: Return with total counts and display limit
|
| 127 |
return {
|
| 128 |
+
'additions': additions[:max_display], # Show first N for UI performance
|
| 129 |
+
'deletions': deletions[:max_display],
|
| 130 |
+
'modifications': modifications[:max_display],
|
| 131 |
+
'total_additions': len(additions), # ✅ TOTAL count
|
| 132 |
+
'total_deletions': len(deletions), # ✅ TOTAL count
|
| 133 |
+
'total_modifications': len(modifications), # ✅ TOTAL count
|
| 134 |
+
'showing_limit': max_display, # ✅ Display limit
|
| 135 |
+
'truncated': len(additions) > max_display or len(deletions) > max_display or len(modifications) > max_display
|
| 136 |
}
|
| 137 |
|
| 138 |
def query_version_graph(self, query: str) -> List[Dict]:
|