Class: LlmCostTracker::Dashboard::DataQuality
- Inherits:
-
Object
- Object
- LlmCostTracker::Dashboard::DataQuality
- Defined in:
- app/services/llm_cost_tracker/dashboard/data_quality.rb
Overview
Computes data quality metrics: coverage of cost, tags, and latency.
Class Method Summary collapse
Class Method Details
.call(scope: LlmCostTracker::LlmApiCall.all) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/llm_cost_tracker/dashboard/data_quality.rb', line 17 def call(scope: LlmCostTracker::LlmApiCall.all) total = scope.count latency_present = LlmCostTracker::LlmApiCall.latency_column? DataQualityStats.new( total_calls: total, unknown_pricing_count: scope.unknown_pricing.count, untagged_calls_count: total - scope..count, missing_latency_count: latency_present ? scope.where(latency_ms: nil).count : nil, latency_column_present: latency_present, unknown_pricing_by_model: scope.unknown_pricing .group(:model) .order(Arel.sql("COUNT(*) DESC")) .count .first(10) .to_h ) end |