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
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
Class Method Summary collapse
Instance Method Summary collapse
- #distinct_values ⇒ Object
-
#initialize(scope:, key:, limit:) ⇒ TagBreakdown
constructor
A new instance of TagBreakdown.
- #rows ⇒ Object
- #tagged_calls ⇒ Object
- #total_calls ⇒ Object
Constructor Details
#initialize(scope:, key:, limit:) ⇒ TagBreakdown
Returns a new instance of TagBreakdown.
16 17 18 19 20 21 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 16 def initialize(scope:, key:, limit:) @scope = scope @key = LlmCostTracker::Tags::Key.validate!(key, error_class: LlmCostTracker::InvalidFilterError) limit = limit.to_i @limit = limit.positive? ? [limit, DEFAULT_LIMIT].min : DEFAULT_LIMIT end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
14 15 16 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 14 def limit @limit end |
Class Method Details
.call(key:, scope: LlmCostTracker::Ledger::Call.all, limit: DEFAULT_LIMIT) ⇒ Object
9 10 11 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 9 def call(key:, scope: LlmCostTracker::Ledger::Call.all, limit: DEFAULT_LIMIT) new(scope: scope, key: key, limit: limit) end |
Instance Method Details
#distinct_values ⇒ Object
35 36 37 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 35 def distinct_values summary_counts.distinct_values.to_i end |
#rows ⇒ Object
23 24 25 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 23 def rows @rows ||= scope.klass.find_by_sql(rows_sql) end |
#tagged_calls ⇒ Object
31 32 33 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 31 def tagged_calls summary_counts.tagged_calls.to_i end |
#total_calls ⇒ Object
27 28 29 |
# File 'app/services/llm_cost_tracker/dashboard/tag_breakdown.rb', line 27 def total_calls summary_counts.total_calls.to_i end |