Class: RubyLLM::Agents::AnalyticsController Private

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/ruby_llm/agents/analytics_controller.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Controller for cost intelligence and analytics

Provides interactive, filterable cost analysis across agents, models, and tenants. The filter bar (agent/model/tenant) applies to all sections, making this an exploration tool rather than a static report.

Constant Summary collapse

VALID_RANGES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[7d 30d 90d custom].freeze
DEFAULT_RANGE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"30d"

Instance Method Summary collapse

Instance Method Details

#chart_dataObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns chart JSON: current period + prior period overlay



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/ruby_llm/agents/analytics_controller.rb', line 33

def chart_data
  @selected_range = sanitize_range(params[:range])
  @days = range_to_days(@selected_range)
  parse_custom_dates if @selected_range == "custom"

  current_scope = apply_filters(time_scoped(tenant_scoped_executions))
  prior_scope = apply_filters(prior_period_scope(tenant_scoped_executions))

  render json: build_overlay_chart_json(current_scope, prior_scope)
end

#indexObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/ruby_llm/agents/analytics_controller.rb', line 16

def index
  @selected_range = sanitize_range(params[:range])
  @days = range_to_days(@selected_range)
  parse_custom_dates if @selected_range == "custom"

  load_filter_options
  base = apply_filters(time_scoped(tenant_scoped_executions))
  prior = apply_filters(prior_period_scope(tenant_scoped_executions))

  load_summary(base, prior)
  load_projection(base)
  load_savings_opportunity(base)
  load_efficiency(base)
  load_error_cost(base)
end