MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / getStats

Method getStats

src/db/queries.ts:1783–1826  ·  view source on GitHub ↗

* Get graph statistics

()

Source from the content-addressed store, hash-verified

1781 * Get graph statistics
1782 */
1783 getStats(): GraphStats {
1784 // Single query for all three aggregate counts
1785 const counts = this.db.prepare(`
1786 SELECT
1787 (SELECT COUNT(*) FROM nodes) AS node_count,
1788 (SELECT COUNT(*) FROM edges) AS edge_count,
1789 (SELECT COUNT(*) FROM files) AS file_count
1790 `).get() as { node_count: number; edge_count: number; file_count: number };
1791
1792 const nodesByKind = {} as Record<NodeKind, number>;
1793 const nodeKindRows = this.db
1794 .prepare('SELECT kind, COUNT(*) as count FROM nodes GROUP BY kind')
1795 .all() as Array<{ kind: string; count: number }>;
1796 for (const row of nodeKindRows) {
1797 nodesByKind[row.kind as NodeKind] = row.count;
1798 }
1799
1800 const edgesByKind = {} as Record<EdgeKind, number>;
1801 const edgeKindRows = this.db
1802 .prepare('SELECT kind, COUNT(*) as count FROM edges GROUP BY kind')
1803 .all() as Array<{ kind: string; count: number }>;
1804 for (const row of edgeKindRows) {
1805 edgesByKind[row.kind as EdgeKind] = row.count;
1806 }
1807
1808 const filesByLanguage = {} as Record<Language, number>;
1809 const languageRows = this.db
1810 .prepare('SELECT language, COUNT(*) as count FROM files GROUP BY language')
1811 .all() as Array<{ language: string; count: number }>;
1812 for (const row of languageRows) {
1813 filesByLanguage[row.language as Language] = row.count;
1814 }
1815
1816 return {
1817 nodeCount: counts.node_count,
1818 edgeCount: counts.edge_count,
1819 fileCount: counts.file_count,
1820 nodesByKind,
1821 edgesByKind,
1822 filesByLanguage,
1823 dbSizeBytes: 0, // Set by caller using DatabaseConnection.getSize()
1824 lastUpdated: Date.now(),
1825 };
1826 }
1827
1828 // ===========================================================================
1829 // Project Metadata

Callers 5

recordIndexEventFunction · 0.45
getToolsMethod · 0.45
handleExploreMethod · 0.45
handleStatusMethod · 0.45
mainFunction · 0.45

Calls 3

getMethod · 0.65
prepareMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected