Class: LlmCostTracker::Dashboard::Filter
- Inherits:
-
Object
- Object
- LlmCostTracker::Dashboard::Filter
- Defined in:
- app/services/llm_cost_tracker/dashboard/filter.rb
Overview
Parses dashboard params into an ActiveRecord relation.
Invalid dates are ignored, pagination is handled elsewhere, and invalid tag keys raise InvalidFilterError so controllers can fail closed with HTTP 400.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(scope:, params:) ⇒ Filter
constructor
A new instance of Filter.
- #relation ⇒ Object
Constructor Details
#initialize(scope:, params:) ⇒ Filter
Returns a new instance of Filter.
18 19 20 21 |
# File 'app/services/llm_cost_tracker/dashboard/filter.rb', line 18 def initialize(scope:, params:) @scope = scope @params = normalize_params(params) end |
Class Method Details
.call(scope: LlmCostTracker::LlmApiCall.all, params: {}) ⇒ Object
13 14 15 |
# File 'app/services/llm_cost_tracker/dashboard/filter.rb', line 13 def call(scope: LlmCostTracker::LlmApiCall.all, params: {}) new(scope: scope, params: params).relation end |
Instance Method Details
#relation ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/services/llm_cost_tracker/dashboard/filter.rb', line 23 def relation filtered_scope = scope filtered_scope = apply_date_filters(filtered_scope) filtered_scope = apply_exact_filter(filtered_scope, :provider) filtered_scope = apply_exact_filter(filtered_scope, :model) apply_tag_filters(filtered_scope) end |