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
19
20
21
22
# 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
  filter_params = LlmCostTracker::ParameterHash.to_hash(params)
  scope = Dashboard::Filter.call(
    params: filter_params.merge("from" => @from_date.iso8601, "to" => @to_date.iso8601)
  )
  previous_scope = Dashboard::Filter.call(
    params: filter_params.merge("from" => prev_from.iso8601, "to" => prev_to.iso8601)
  )

  @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 = Dashboard::TopModels.call(scope: scope)
  @providers = Dashboard::ProviderBreakdown.call(scope: scope)
end