path
This commit is contained in:
+13
-11
@@ -3043,8 +3043,8 @@ Example - health_check() → { "status":"ready","total_chunks":11234,"graph_node
|
||||
except:
|
||||
repo_info = "Git repository (no branch info)"
|
||||
|
||||
# Load graph to check if it exists
|
||||
graph = LocalGraph(str(CODEBASE_PATH))
|
||||
# Load graph to check if it exists - FIX: Convert Path to string
|
||||
graph = LocalGraph(root_path=str(CODEBASE_PATH)) # Convert Path to str
|
||||
graph_loaded = graph.load()
|
||||
|
||||
status = {
|
||||
@@ -3080,7 +3080,7 @@ Example - health_check() → { "status":"ready","total_chunks":11234,"graph_node
|
||||
"index_age_hours": round((time.time() - index_build_time) / 3600, 1) if index_build_time > 0 else None
|
||||
}
|
||||
|
||||
# Add graph statistics
|
||||
# Add graph statistics - FIX: Use graph.graph.nodes instead of graph.nodes
|
||||
if graph_loaded:
|
||||
graph_stats = _calculate_graph_stats(graph)
|
||||
status["graph"] = graph_stats
|
||||
@@ -3098,6 +3098,7 @@ Example - health_check() → { "status":"ready","total_chunks":11234,"graph_node
|
||||
|
||||
def _calculate_graph_stats(graph: LocalGraph) -> dict:
|
||||
"""Calculate comprehensive graph statistics."""
|
||||
# FIX: Use graph.graph.nodes and graph.graph.edges instead of graph.nodes/graph.edges
|
||||
if graph.graph.number_of_nodes() == 0:
|
||||
return {"status": "empty", "nodes": 0, "edges": 0}
|
||||
|
||||
@@ -3107,34 +3108,34 @@ def _calculate_graph_stats(graph: LocalGraph) -> dict:
|
||||
|
||||
# Count by node type
|
||||
node_types = {}
|
||||
for _, data in graph.graph.nodes(data=True):
|
||||
for _, data in graph.graph.nodes(data=True): # FIX: graph.graph.nodes
|
||||
node_type = data.get('type', 'unknown')
|
||||
node_types[node_type] = node_types.get(node_type, 0) + 1
|
||||
|
||||
# Count by edge type
|
||||
edge_types = {}
|
||||
for _, _, data in graph.graph.edges(data=True):
|
||||
for _, _, data in graph.graph.edges(data=True): # FIX: graph.graph.edges
|
||||
edge_type = data.get('type', 'unknown')
|
||||
edge_types[edge_type] = edge_types.get(edge_type, 0) + 1
|
||||
|
||||
# Language distribution
|
||||
languages = {}
|
||||
for _, data in graph.graph.nodes(data=True):
|
||||
lang = data.get('language', 'unknown')
|
||||
for _, data in graph.graph.nodes(data=True): # FIX: graph.graph.nodes
|
||||
lang = data.get('lang', 'unknown') # Changed from 'language' to 'lang' to match our new attribute
|
||||
languages[lang] = languages.get(lang, 0) + 1
|
||||
|
||||
# File statistics
|
||||
files = [n for n, d in graph.graph.nodes(data=True) if d.get('type') == 'File']
|
||||
files = [n for n, d in graph.graph.nodes(data=True) if d.get('type') == 'File'] # FIX: graph.graph.nodes
|
||||
|
||||
# Relationship density
|
||||
avg_edges_per_node = edges / nodes if nodes > 0 else 0
|
||||
|
||||
# Most connected nodes (hubs)
|
||||
degree_centrality = dict(graph.graph.degree())
|
||||
degree_centrality = dict(graph.graph.degree()) # FIX: graph.graph.degree()
|
||||
top_hubs = sorted(degree_centrality.items(), key=lambda x: x[1], reverse=True)[:5]
|
||||
top_hubs_info = []
|
||||
for node_id, degree in top_hubs:
|
||||
node_data = graph.graph.nodes[node_id]
|
||||
node_data = graph.graph.nodes[node_id] # FIX: graph.graph.nodes
|
||||
top_hubs_info.append({
|
||||
"name": node_data.get('name', node_id),
|
||||
"type": node_data.get('type', 'unknown'),
|
||||
@@ -3170,7 +3171,8 @@ Example: search_codebase("user authentication", 5, True) → 5 results with code
|
||||
if vectorstore is None or bm25_corpus is None:
|
||||
return "❌ Index not built. Please call init_repo() or rebuild_index() first."
|
||||
|
||||
graph = LocalGraph(CODEBASE_PATH)
|
||||
# FIX: Convert Path to string
|
||||
graph = LocalGraph(root_path=str(CODEBASE_PATH))
|
||||
graph_loaded = graph.load()
|
||||
|
||||
if not graph_loaded:
|
||||
|
||||
Reference in New Issue
Block a user