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

Method getModelStats

src/utils/telemetry.ts:211–231  ·  view source on GitHub ↗

Model stats over the last N days.

(daysBack = 30, cwd?: string)

Source from the content-addressed store, hash-verified

209
210 /** Model stats over the last N days. */
211 getModelStats(daysBack = 30, cwd?: string): ModelStats[] {
212 const db = this.ensureOpen();
213 if (!db) return [];
214 const since = Date.now() - daysBack * 24 * 60 * 60 * 1000;
215 const whereCwd = cwd ? ' AND cwd = ?' : '';
216 const params: (string | number)[] = [since];
217 if (cwd) params.push(this.maskCwd(cwd));
218 const rows = db.prepare(`
219 SELECT provider, model, role,
220 COUNT(*) as callCount,
221 SUM(input_tokens) as totalInputTokens,
222 SUM(output_tokens) as totalOutputTokens,
223 SUM(cost_usd) as totalCostUsd,
224 AVG(duration_ms) as avgDurationMs
225 FROM llm_events
226 WHERE ts >= ?${whereCwd}
227 GROUP BY provider, model, role
228 ORDER BY callCount DESC
229 `).all(...params) as ModelStats[];
230 return rows;
231 }
232
233 /** Wipe local telemetry DB. */
234 clear(): { toolEventsDeleted: number; llmEventsDeleted: number } {

Callers 1

handleSlashCommandFunction · 0.80

Calls 3

ensureOpenMethod · 0.95
maskCwdMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected