MCPcopy
hub / github.com/tirth8205/code-review-graph / take_snapshot

Function take_snapshot

code_review_graph/graph_diff.py:15–43  ·  view source on GitHub ↗

Take a snapshot of the current graph state. Returns a dict with node and edge counts, qualified names, and community assignments for later diffing.

(store: GraphStore)

Source from the content-addressed store, hash-verified

13
14
15def take_snapshot(store: GraphStore) -> dict[str, Any]:
16 """Take a snapshot of the current graph state.
17
18 Returns a dict with node and edge counts, qualified names,
19 and community assignments for later diffing.
20 """
21 stats = store.get_stats()
22 nodes = store.get_all_nodes(exclude_files=False)
23 community_map = store.get_all_community_ids()
24
25 return {
26 "node_count": stats.total_nodes,
27 "edge_count": stats.total_edges,
28 "nodes": {
29 n.qualified_name: {
30 "kind": n.kind,
31 "file": n.file_path,
32 "community_id": community_map.get(
33 n.qualified_name
34 ),
35 }
36 for n in nodes
37 },
38 "edges": {
39 f"{e.source_qualified}->"
40 f"{e.target_qualified}:{e.kind}"
41 for e in store.get_all_edges()
42 },
43 }
44
45
46def save_snapshot(snapshot: dict, path: Path) -> None:

Callers

nothing calls this directly

Calls 5

get_statsMethod · 0.80
get_all_nodesMethod · 0.80
get_all_community_idsMethod · 0.80
getMethod · 0.80
get_all_edgesMethod · 0.80

Tested by

no test coverage detected