MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / getToolStats

Method getToolStats

src/utils/telemetry.ts:188–208  ·  view source on GitHub ↗

Tool stats over the last N days.

(daysBack = 30, cwd?: string)

Source from the content-addressed store, hash-verified

186
187 /** Tool stats over the last N days. */
188 getToolStats(daysBack = 30, cwd?: string): ToolStats[] {
189 const db = this.ensureOpen();
190 if (!db) return [];
191 const since = Date.now() - daysBack * 24 * 60 * 60 * 1000;
192 const whereCwd = cwd ? ' AND cwd = ?' : '';
193 const params: (string | number)[] = [since];
194 if (cwd) params.push(this.maskCwd(cwd));
195 const rows = db.prepare(`
196 SELECT tool,
197 COUNT(*) as totalCalls,
198 SUM(success) as successCount,
199 SUM(1 - success) as failCount,
200 AVG(duration_ms) as avgDurationMs,
201 SUM(duration_ms) as totalDurationMs
202 FROM tool_events
203 WHERE ts >= ?${whereCwd}
204 GROUP BY tool
205 ORDER BY totalCalls DESC
206 `).all(...params) as ToolStats[];
207 return rows;
208 }
209
210 /** Model stats over the last N days. */
211 getModelStats(daysBack = 30, cwd?: string): ModelStats[] {

Callers 1

handleSlashCommandFunction · 0.80

Calls 3

ensureOpenMethod · 0.95
maskCwdMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected