Class: LlmCostTracker::Dashboard::TagBreakdown
- Inherits:
-
Object
- Object
- LlmCostTracker::Dashboard::TagBreakdown
- Defined in:
- app/services/llm_cost_tracker/dashboard/tag_breakdown.rb
Constant Summary collapse
- DEFAULT_LIMIT =
100
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scope:, key:, limit:) ⇒ TagBreakdown
constructor
A new instance of TagBreakdown.
- #result ⇒ Object
Constructor Details
#initialize(scope:, key:, limit:) ⇒ TagBreakdown
Returns a new instance of TagBreakdown.
31 32 33 34 35 36 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 31 def initialize(scope:, key:, limit:) @scope = scope @key = LlmCostTracker::TagKey.validate!(key, error_class: LlmCostTracker::InvalidFilterError) @limit = normalized_limit(limit) @connection = LlmCostTracker::LlmApiCall.connection end |
Class Method Details
.call(key:, scope: LlmCostTracker::LlmApiCall.all, limit: DEFAULT_LIMIT) ⇒ Object
26 27 28 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 26 def call(key:, scope: LlmCostTracker::LlmApiCall.all, limit: DEFAULT_LIMIT) new(scope: scope, key: key, limit: limit).result end |
Instance Method Details
#result ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 38 def result counts = summary_counts TagBreakdownResult.new( rows: rows, total_calls: counts.fetch(:total_calls), tagged_calls: counts.fetch(:tagged_calls), distinct_values: counts.fetch(:distinct_values), limit: limit ) end |