MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / generationTimeCountExprSql

Function generationTimeCountExprSql

apps/web/src/routers/usage-analytics-router.ts:410–418  ·  view source on GitHub ↗
(tier: GranularityTier)

Source from the content-addressed store, hash-verified

408 case 'outputInputRatio':
409 return 'CASE WHEN COALESCE(SUM(total_input_tokens), 0) = 0 THEN 0 ELSE COALESCE(SUM(total_output_tokens), 0)::FLOAT / SUM(total_input_tokens)::FLOAT END';
410 }
411}
412
413function generationTimeCountExprSql(tier: GranularityTier): string {
414 if (tier === 'hourly') {
415 return 'IFF(total_generation_time_ms IS NOT NULL, 1, 0)';
416 }
417 // Daily rollups do not currently carry a generation-time observation count.
418 // Derive one only for the window backed by hourly rollups so older daily
419 // history does not reuse latency_count as an incorrect denominator.
420 return 'IFF(total_generation_time_ms IS NOT NULL AND usage_date >= DATEADD(day, -7, CURRENT_DATE), 1, 0)';
421}

Callers 2

metricExprSqlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected