Class: Raif::Admin::Stats::TasksController

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

Instance Method Summary collapse

Methods inherited from Raif::ApplicationController

#raif_current_user

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/raif/admin/stats/tasks_controller.rb', line 7

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

  @task_count = Raif::Task.where(created_at: @time_range).count

  # Get task counts by type
  @task_counts_by_type = Raif::Task.where(created_at: @time_range).group(:type).count

  # Get costs by task type
  @task_costs_by_type = Raif::Task.joins(:raif_model_completion)
    .where(created_at: @time_range)
    .group(:type)
    .sum("raif_model_completions.total_cost")
end