Class: Raif::Admin::StatsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/raif/admin/stats_controller.rb

Instance Method Summary collapse

Methods inherited from Raif::ApplicationController

#raif_current_user

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/raif/admin/stats_controller.rb', line 6

def index
  @selected_period = params[:period] || "day"
  @time_range = get_time_range(@selected_period)

  @model_completion_count = Raif::ModelCompletion.where(created_at: @time_range).count
  @model_completion_total_cost = Raif::ModelCompletion.where(created_at: @time_range).sum(:total_cost)
  @task_count = Raif::Task.where(created_at: @time_range).count
  @conversation_count = Raif::Conversation.where(created_at: @time_range).count
  @conversation_entry_count = Raif::ConversationEntry.where(created_at: @time_range).count
  @agent_count = Raif::Agent.where(created_at: @time_range).count
end