Class: GoodJob::CleanerController

Inherits:
ApplicationController show all
Defined in:
app/controllers/good_job/cleaner_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
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/good_job/cleaner_controller.rb', line 5

def index
  @filter = JobsFilter.new(params)

  @discarded_jobs_grouped_by_exception =
    GoodJob::Job.discarded
                .select("                  SPLIT_PART(error, ': ', 1) AS exception_class,\n                  count(id) AS failed,\n                  COUNT(id) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '1 HOUR') AS last_1_hour,\n                  COUNT(id) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '3 HOURS') AS last_3_hours,\n                  COUNT(id) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '24 HOURS') AS last_24_hours,\n                  COUNT(id) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '3 DAYS') AS last_3_days,\n                  COUNT(id) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '7 DAYS') AS last_7_days\n                SQL\n                .order(:exception_class)\n                .group(:exception_class)\n\n  @discarded_jobs_grouped_by_class =\n    GoodJob::Job.discarded\n                .select(<<-SQL.squish)\n                  job_class,\n                  count(id) AS failed,\n                  COUNT(*) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '1 HOUR') AS last_1_hour,\n                  COUNT(*) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '3 HOURS') AS last_3_hours,\n                  COUNT(*) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '24 HOURS') AS last_24_hours,\n                  COUNT(*) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '3 DAYS') AS last_3_days,\n                  COUNT(*) FILTER (WHERE \"finished_at\" > NOW() - INTERVAL '7 DAYS') AS last_7_days\n                SQL\n                .order(:job_class)\n                .group(:job_class)\nend\n".squish)