Class: LlmCostTracker::DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/llm_cost_tracker/dashboard_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/llm_cost_tracker/dashboard_controller.rb', line 5

def index
  @from_date, @to_date = overview_range
  prev_from, prev_to = previous_range
  scope = Dashboard::Filter.call(params: overview_filter_params)
  previous_scope = Dashboard::Filter.call(params: previous_filter_params)
  model_rows = Dashboard::TopModels.call(scope: scope, limit: 10)

  @stats = Dashboard::OverviewStats.call(scope: scope, previous_scope: previous_scope)
  @time_series = Dashboard::TimeSeries.call(scope: scope, from: @from_date, to: @to_date)
  @comparison_series = Dashboard::TimeSeries.call(scope: previous_scope, from: prev_from, to: prev_to)
  @spend_anomaly = Dashboard::SpendAnomaly.call(from: @from_date, to: @to_date, scope: scope)
  @top_models = model_rows.first(5)
  @providers = Dashboard::ProviderBreakdown.call(scope: scope)
end