diff --git a/app/controllers/good_job/cleaner_controller.rb b/app/controllers/good_job/cleaner_controller.rb
new file mode 100644
index 00000000..dfc48ef9
--- /dev/null
+++ b/app/controllers/good_job/cleaner_controller.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module GoodJob
+ class CleanerController < ApplicationController
+ def index
+ @filter = JobsFilter.new(params)
+
+ @discarded_jobs_grouped_by_exception =
+ GoodJob::Job.discarded
+ .select(<<-SQL.squish)
+ SPLIT_PART(error, ': ', 1) AS exception_class,
+ count(id) AS failed,
+ COUNT(id) FILTER (WHERE "finished_at" > NOW() - INTERVAL '1 HOUR') AS last_1_hour,
+ COUNT(id) FILTER (WHERE "finished_at" > NOW() - INTERVAL '3 HOURS') AS last_3_hours,
+ COUNT(id) FILTER (WHERE "finished_at" > NOW() - INTERVAL '24 HOURS') AS last_24_hours,
+ COUNT(id) FILTER (WHERE "finished_at" > NOW() - INTERVAL '3 DAYS') AS last_3_days,
+ COUNT(id) FILTER (WHERE "finished_at" > NOW() - INTERVAL '7 DAYS') AS last_7_days
+ SQL
+ .order(:exception_class)
+ .group(:exception_class)
+
+ @discarded_jobs_grouped_by_class =
+ GoodJob::Job.discarded
+ .select(<<-SQL.squish)
+ job_class,
+ count(id) AS failed,
+ COUNT(*) FILTER (WHERE "finished_at" > NOW() - INTERVAL '1 HOUR') AS last_1_hour,
+ COUNT(*) FILTER (WHERE "finished_at" > NOW() - INTERVAL '3 HOURS') AS last_3_hours,
+ COUNT(*) FILTER (WHERE "finished_at" > NOW() - INTERVAL '24 HOURS') AS last_24_hours,
+ COUNT(*) FILTER (WHERE "finished_at" > NOW() - INTERVAL '3 DAYS') AS last_3_days,
+ COUNT(*) FILTER (WHERE "finished_at" > NOW() - INTERVAL '7 DAYS') AS last_7_days
+ SQL
+ .order(:job_class)
+ .group(:job_class)
+ end
+ end
+end
diff --git a/app/controllers/good_job/metrics_controller.rb b/app/controllers/good_job/metrics_controller.rb
index 8096aa85..01d7543e 100644
--- a/app/controllers/good_job/metrics_controller.rb
+++ b/app/controllers/good_job/metrics_controller.rb
@@ -7,12 +7,14 @@ def primary_nav
batches_count = GoodJob::BatchRecord.all.size
cron_entries_count = GoodJob::CronEntry.all.size
processes_count = GoodJob::Process.active.count
+ discarded_count = GoodJob::Job.discarded.count
render json: {
jobs_count: helpers.number_to_human(jobs_count),
batches_count: helpers.number_to_human(batches_count),
cron_entries_count: helpers.number_to_human(cron_entries_count),
processes_count: helpers.number_to_human(processes_count),
+ discarded_count: helpers.number_to_human(discarded_count),
}
end
diff --git a/app/filters/good_job/base_filter.rb b/app/filters/good_job/base_filter.rb
index e6a35e0a..effffe86 100644
--- a/app/filters/good_job/base_filter.rb
+++ b/app/filters/good_job/base_filter.rb
@@ -54,6 +54,7 @@ def to_params(override = {})
query: params[:query],
state: params[:state],
cron_key: params[:cron_key],
+ finished_since: params[:finished_since],
}.merge(override).delete_if { |_, v| v.blank? }
end
diff --git a/app/filters/good_job/jobs_filter.rb b/app/filters/good_job/jobs_filter.rb
index dc366d6a..c4b5ff07 100644
--- a/app/filters/good_job/jobs_filter.rb
+++ b/app/filters/good_job/jobs_filter.rb
@@ -27,6 +27,7 @@ def filtered_query(filter_params = params)
query = query.where(queue_name: filter_params[:queue_name]) if filter_params[:queue_name].present?
query = query.search_text(filter_params[:query]) if filter_params[:query].present?
query = query.where(cron_key: filter_params[:cron_key]) if filter_params[:cron_key].present?
+ query = query.where(finished_at: finished_since(filter_params[:finished_since])..) if filter_params[:finished_since].present?
if filter_params[:state]
case filter_params[:state]
@@ -61,5 +62,20 @@ def query_for_records
def default_base_query
GoodJob::Job.all
end
+
+ def finished_since(finished_since)
+ case finished_since
+ when '1_hour_ago'
+ 1.hour.ago
+ when '3_hours_ago'
+ 3.hours.ago
+ when '24_hours_ago'
+ 24.hours.ago
+ when '3_days_ago'
+ 3.days.ago
+ when '7_days_ago'
+ 7.days.ago
+ end
+ end
end
end
diff --git a/app/views/good_job/cleaner/index.html.erb b/app/views/good_job/cleaner/index.html.erb
new file mode 100644
index 00000000..cfe19ec6
--- /dev/null
+++ b/app/views/good_job/cleaner/index.html.erb
@@ -0,0 +1,85 @@
+
+
<%= t ".title" %>
+
+
+
+
<%= t ".grouped_by_class" %>
+
+
+
+ <%= t ".class" %> |
+ <%= t ".all" %> |
+ <%= t ".last_1_hour" %> |
+ <%= t ".last_3_hours" %> |
+ <%= t ".last_24_hours" %> |
+ <%= t ".last_3_days" %> |
+ <%= t ".last_7_days" %> |
+
+
+
+ <% @discarded_jobs_grouped_by_class.each do |discard_job| %>
+
+ <%= discard_job.job_class %> |
+ <%= link_to discard_job.failed, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded')) %> |
+ <%= link_to discard_job.last_1_hour, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded', finished_since: '1_hour_ago')) %> |
+ <%= link_to discard_job.last_3_hours, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded', finished_since: '3_hours_ago')) %> |
+ <%= link_to discard_job.last_24_hours, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded', finished_since: '24_hours_ago')) %> |
+ <%= link_to discard_job.last_3_days, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded', finished_since: '3_days_ago')) %> |
+ <%= link_to discard_job.last_7_days, jobs_path(@filter.to_params(job_class: discard_job.job_class, state: 'discarded', finished_since: '7_days_ago')) %> |
+
+ <% end %>
+
+
+
+ <%= t ".total" %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:failed), jobs_path(@filter.to_params(state: 'discarded')) %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:last_1_hour), jobs_path(@filter.to_params(state: 'discarded', finished_since: '1_hour_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:last_3_hours), jobs_path(@filter.to_params(state: 'discarded', finished_since: '3_hours_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:last_24_hours), jobs_path(@filter.to_params(state: 'discarded', finished_since: '24_hours_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:last_3_days), jobs_path(@filter.to_params(state: 'discarded', finished_since: '3_days_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_class.sum(&:last_7_days), jobs_path(@filter.to_params(state: 'discarded', finished_since: '7_days_ago')) %> |
+
+
+
+
+
+
+
<%= t ".grouped_by_exception" %>
+
+
+
+ <%= t ".exception" %> |
+ <%= t ".all" %> |
+ <%= t ".last_1_hour" %> |
+ <%= t ".last_3_hours" %> |
+ <%= t ".last_24_hours" %> |
+ <%= t ".last_3_days" %> |
+ <%= t ".last_7_days" %> |
+
+
+
+ <% @discarded_jobs_grouped_by_exception.each do |discard_job| %>
+
+ <%= discard_job.exception_class %> |
+ <%= link_to discard_job.failed, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class)) %> |
+ <%= link_to discard_job.last_1_hour, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class, finished_since: '1_hour_ago')) %> |
+ <%= link_to discard_job.last_3_hours, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class, finished_since: '3_hours_ago')) %> |
+ <%= link_to discard_job.last_24_hours, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class, finished_since: '24_hours_ago')) %> |
+ <%= link_to discard_job.last_3_days, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class, finished_since: '3_days_ago')) %> |
+ <%= link_to discard_job.last_7_days, jobs_path(@filter.to_params(state: 'discarded', query: discard_job.exception_class, finished_since: '7_days_ago')) %> |
+
+ <% end %>
+
+
+
+ <%= t ".total" %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:failed), jobs_path(@filter.to_params(state: 'discarded')) %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:last_1_hour), jobs_path(@filter.to_params(state: 'discarded', finished_since: '1_hour_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:last_3_hours), jobs_path(@filter.to_params(state: 'discarded', finished_since: '3_hours_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:last_24_hours), jobs_path(@filter.to_params(state: 'discarded', finished_since: '24_hours_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:last_3_days), jobs_path(@filter.to_params(state: 'discarded', finished_since: '3_days_ago')) %> |
+ <%= link_to @discarded_jobs_grouped_by_exception.sum(&:last_7_days), jobs_path(@filter.to_params(state: 'discarded', finished_since: '7_days_ago')) %> |
+
+
+
+
diff --git a/app/views/good_job/shared/_navbar.erb b/app/views/good_job/shared/_navbar.erb
index 375abd48..29b7f743 100644
--- a/app/views/good_job/shared/_navbar.erb
+++ b/app/views/good_job/shared/_navbar.erb
@@ -44,6 +44,12 @@
<%= t(".performance") %>
<% end %>
+
+ <%= link_to cleaner_index_path, class: ["nav-link", ("active" if controller_name == 'cleaner')] do %>
+ <%= t(".cleaner") %>
+
+ <% end %>
+
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 438dc4b9..23d53125 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -35,6 +35,20 @@ de:
callback_jobs: Callback-Jobs
table:
no_batches_found: Keine Batches gefunden.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Bist du sicher, dass du diesen Cron-Eintrag deaktivieren willst?
@@ -236,6 +250,7 @@ de:
search: Suchen
navbar:
batches: Batches
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Jobs
live_poll: Live Poll
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3a2640f5..af62b5d4 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -35,6 +35,20 @@ en:
callback_jobs: Callback Jobs
table:
no_batches_found: No batches found.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Are you sure you want to disable this cron entry?
@@ -236,6 +250,7 @@ en:
search: Search
navbar:
batches: Batches
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Jobs
live_poll: Live Poll
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 8fad8d4d..14c6b6f9 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -35,6 +35,20 @@ es:
callback_jobs: Callback Jobs
table:
no_batches_found: No hay lotes.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: "¿Estás seguro que querés deshabilitar esta tarea programada?"
@@ -236,6 +250,7 @@ es:
search: Buscar
navbar:
batches: Lotes
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Tareas
live_poll: En vivo
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 46ce4a91..2b76420e 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -35,6 +35,20 @@ fr:
callback_jobs: Jobs de rappel
table:
no_batches_found: Aucun lot trouvé.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Voulez-vous vraiment désactiver cette entrée cron ?
@@ -236,6 +250,7 @@ fr:
search: Rechercher
navbar:
batches: Lots
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Jobs
live_poll: En direct
diff --git a/config/locales/it.yml b/config/locales/it.yml
index fb4b7eda..6fc315c1 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -35,6 +35,20 @@ it:
callback_jobs: Job di callback
table:
no_batches_found: Nessun batch trovato.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Sei sicuro di voler disabilitare questa voce cron?
@@ -236,6 +250,7 @@ it:
search: Cerca
navbar:
batches: Batch
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Job
live_poll: Live Poll
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 5fabb223..09a0830f 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -35,6 +35,20 @@ ja:
callback_jobs: コールバックジョブ
table:
no_batches_found: バッチが見つかりませんでした。
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: このcronエントリを無効化してもよろしいですか?
@@ -236,6 +250,7 @@ ja:
search: 検索
navbar:
batches: バッチ
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: ジョブ
live_poll: リアルタイム更新
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 42d4b5a0..0db416c7 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -35,6 +35,20 @@ ko:
callback_jobs: 콜백 작업
table:
no_batches_found: 배치를 찾을 수 없습니다.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: 이 cron 엔트리를 비활성화하시겠습니까?
@@ -236,6 +250,7 @@ ko:
search: 검색
navbar:
batches: 배치
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: 작업
live_poll: 실시간 업데이트
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index c8a67b97..6223af4b 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -35,6 +35,20 @@ nl:
callback_jobs: Terugbelopdrachten
table:
no_batches_found: Geen batches gevonden.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Weet u zekerf dat u deze cron-vermelding wilt uitschakelen?
@@ -236,6 +250,7 @@ nl:
search: Zoekopdracht
navbar:
batches: Batches
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Taken
live_poll: Live Poll
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index d2598c49..1269f050 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -35,6 +35,20 @@ pt-BR:
callback_jobs: Tarefas de Callback
table:
no_batches_found: Nenhum lote encontrado.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Tem certeza de que deseja desativar esta tarefa programada?
@@ -236,6 +250,7 @@ pt-BR:
search: Pesquisar
navbar:
batches: Lotes
+ cleaner: Discard Cleaner
cron_schedules: Agendamentos
jobs: Tarefas
live_poll: Acompanhamento ao Vivo
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 3f624056..0652bfb6 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -35,6 +35,20 @@ ru:
callback_jobs: Коллбеки
table:
no_batches_found: Группы заданий не найдены.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Вы уверены, что хотите отключить эту задачу cron?
@@ -262,6 +276,7 @@ ru:
search: Поиск
navbar:
batches: Пакетные задания
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Задания
live_poll: Обновления в реальном времени
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index d568dc90..16a65419 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -35,6 +35,20 @@ tr:
callback_jobs: Geri Çağırma İşleri
table:
no_batches_found: Toplu İşlem bulunamadı.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Bu cron girişini devre dışı bırakmak istediğinizden emin misiniz?
@@ -236,6 +250,7 @@ tr:
search: Ara
navbar:
batches: Toplu İşler
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: İşler
live_poll: Anlık Güncelleme
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index b83651d8..157488ed 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -35,6 +35,20 @@ uk:
callback_jobs: Задачі з зворотнім викликом
table:
no_batches_found: Пакети не знайдені.
+ cleaner:
+ index:
+ all: All
+ class: Class
+ exception: Exception
+ grouped_by_class: Discards grouped by Class
+ grouped_by_exception: Discards grouped by Exception
+ last_1_hour: Last 1 hour
+ last_24_hours: Last 24 hours
+ last_3_days: Last 3 days
+ last_3_hours: Last 3 hours
+ last_7_days: Last 7 days
+ title: Discard Cleaner
+ total: Total
cron_entries:
actions:
confirm_disable: Ви впевнені, що хочете вимкнути цю cron-запис?
@@ -262,6 +276,7 @@ uk:
search: Пошук
navbar:
batches: Пакети
+ cleaner: Discard Cleaner
cron_schedules: Cron
jobs: Задачі
live_poll: Живе Опитування
diff --git a/config/routes.rb b/config/routes.rb
index ecb5ad3b..922a2d77 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -34,8 +34,8 @@
end
resources :processes, only: %i[index]
-
resources :performance, only: %i[index show]
+ resources :cleaner, only: %i[index]
scope :frontend, controller: :frontends, defaults: { version: GoodJob::VERSION.tr(".", "-") } do
get "modules/:version/:id", action: :module, as: :frontend_module, constraints: { format: 'js' }
diff --git a/spec/app/filters/good_job/jobs_filter_spec.rb b/spec/app/filters/good_job/jobs_filter_spec.rb
index 64e7b93a..ae7a26ac 100644
--- a/spec/app/filters/good_job/jobs_filter_spec.rb
+++ b/spec/app/filters/good_job/jobs_filter_spec.rb
@@ -114,6 +114,18 @@
expect(filter.records.size).to eq 1
end
end
+
+ context 'when filtered by finished_since' do
+ before do
+ GoodJob::Job.find_each { |job| job.update!(finished_at: 6.hours.ago) }
+ GoodJob::Job.take.update!(finished_at: 30.minutes.ago)
+ params[:finished_since] = '1_hour_ago'
+ end
+
+ it 'filters results' do
+ expect(filter.records.size).to eq 1
+ end
+ end
end
describe '#filtered_count' do
diff --git a/spec/requests/good_job/metrics_controller_spec.rb b/spec/requests/good_job/metrics_controller_spec.rb
index 6d615eb2..6fa0dcba 100644
--- a/spec/requests/good_job/metrics_controller_spec.rb
+++ b/spec/requests/good_job/metrics_controller_spec.rb
@@ -13,6 +13,7 @@
batches_count: '0',
cron_entries_count: '1',
processes_count: '0',
+ discarded_count: '0',
}.to_json
)
end
diff --git a/spec/system/cleaner_spec.rb b/spec/system/cleaner_spec.rb
new file mode 100644
index 00000000..f92a9136
--- /dev/null
+++ b/spec/system/cleaner_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe 'Cleaner Page', :js do
+ let(:discarded_job) do
+ Timecop.travel 1.hour.ago
+ ExampleJob.set(queue: :elephants).perform_later(ExampleJob::DEAD_TYPE)
+ 5.times do
+ Timecop.travel 5.minutes
+ GoodJob.perform_inline
+ end
+ Timecop.return
+ GoodJob::Job.order(created_at: :asc).last
+ end
+
+ before do
+ ActiveJob::Base.queue_adapter = GoodJob::Adapter.new(execution_mode: :inline)
+ discarded_job
+ end
+
+ it 'render index properly' do
+ visit good_job.root_path
+ click_link 'Cleaner'
+ expect(page).to have_css 'h2', text: 'Cleaner'
+ end
+
+ it 'redirects to jobs discarded page with job filtered' do
+ visit '/good_job/cleaner'
+
+ expect(page).to have_content 'DeadError'
+
+ page.find('table#by-job-class tbody tr:first-child td:nth-child(2)').click_link '1'
+
+ expect(page).to have_css 'h2', text: 'Jobs'
+ expect(page).to have_content 'Error: ExampleJob::DeadError'
+
+ expect(find('#filter a.nav-link.active span')).to have_content '1'
+ end
+end