MCPcopy Index your code
hub / github.com/tirth8205/code-review-graph / get_stats

Method get_stats

code_review_graph/graph.py:834–867  ·  view source on GitHub ↗

Return aggregate statistics about the graph.

(self)

Source from the content-addressed store, hash-verified

832 return {"nodes": nodes, "edges": edges}
833
834 def get_stats(self) -> GraphStats:
835 """Return aggregate statistics about the graph."""
836 total_nodes = self._conn.execute("SELECT COUNT(*) FROM nodes").fetchone()[0]
837 total_edges = self._conn.execute("SELECT COUNT(*) FROM edges").fetchone()[0]
838
839 nodes_by_kind: dict[str, int] = {}
840 for row in self._conn.execute("SELECT kind, COUNT(*) as cnt FROM nodes GROUP BY kind"):
841 nodes_by_kind[row["kind"]] = row["cnt"]
842
843 edges_by_kind: dict[str, int] = {}
844 for row in self._conn.execute("SELECT kind, COUNT(*) as cnt FROM edges GROUP BY kind"):
845 edges_by_kind[row["kind"]] = row["cnt"]
846
847 languages = [
848 r["language"] for r in self._conn.execute(
849 "SELECT DISTINCT language FROM nodes WHERE language IS NOT NULL AND language != ''"
850 )
851 ]
852
853 files_count = self._conn.execute(
854 "SELECT COUNT(*) FROM nodes WHERE kind = 'File'"
855 ).fetchone()[0]
856
857 last_updated = self.get_metadata("last_updated")
858
859 return GraphStats(
860 total_nodes=total_nodes,
861 total_edges=total_edges,
862 nodes_by_kind=nodes_by_kind,
863 edges_by_kind=edges_by_kind,
864 languages=languages,
865 files_count=files_count,
866 last_updated=last_updated,
867 )
868
869 def get_nodes_by_size(
870 self,

Callers 11

mainFunction · 0.95
test_full_pipelineMethod · 0.80
test_statsMethod · 0.80
test_get_statsMethod · 0.80
export_graph_dataFunction · 0.80
generate_htmlFunction · 0.80
take_snapshotFunction · 0.80
get_minimal_contextFunction · 0.80
list_graph_statsFunction · 0.80
runFunction · 0.80

Calls 2

get_metadataMethod · 0.95
GraphStatsClass · 0.70

Tested by 4

test_full_pipelineMethod · 0.64
test_statsMethod · 0.64
test_get_statsMethod · 0.64