Module: LlmCostTracker::DashboardFilterHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/llm_cost_tracker/dashboard_filter_helper.rb
Constant Summary collapse
- FILTER_PARAM_KEYS =
%i[from to provider model stream usage_source tag sort page per].freeze
- STREAM_FILTER_OPTIONS =
[ ["Streaming only", "yes"], ["Non-streaming only", "no"] ].freeze
Instance Method Summary collapse
- #active_tag_filters ⇒ Object
- #any_filter_applied? ⇒ Boolean
- #dashboard_date_range_label(from, to) ⇒ Object
Instance Method Details
#active_tag_filters ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/llm_cost_tracker/dashboard_filter_helper.rb', line 16 def active_tag_filters tag_params = (params[:tag]) return [] unless tag_params.is_a?(Hash) tag_params.filter_map do |key, value| next if key.blank? || value.blank? { label: "Tag", value: "#{key}=#{value}", path: dashboard_filter_path(current_query(tag: tag_params.except(key.to_s).presence, page: nil)) } end end |
#any_filter_applied? ⇒ Boolean
12 13 14 |
# File 'app/helpers/llm_cost_tracker/dashboard_filter_helper.rb', line 12 def any_filter_applied? FILTER_PARAM_KEYS.any? { |key| params[key].present? } end |
#dashboard_date_range_label(from, to) ⇒ Object
31 32 33 34 35 |
# File 'app/helpers/llm_cost_tracker/dashboard_filter_helper.rb', line 31 def dashboard_date_range_label(from, to) from_label = short_date_label(from) || "Any time" to_label = short_date_label(to) || "Now" "#{from_label} - #{to_label}" end |