From ce92c2173ecb24a1c1f6df77291d2024ecddfd4d Mon Sep 17 00:00:00 2001 From: "Ben Sheldon [he/him]" Date: Tue, 28 Feb 2023 07:29:04 -0800 Subject: [PATCH] Don't load all Executions on Jobs Dashboard --- app/filters/good_job/jobs_filter.rb | 24 +++++++++++++----------- app/views/good_job/jobs/_table.erb | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/filters/good_job/jobs_filter.rb b/app/filters/good_job/jobs_filter.rb index d8985943a..788a861df 100644 --- a/app/filters/good_job/jobs_filter.rb +++ b/app/filters/good_job/jobs_filter.rb @@ -2,15 +2,17 @@ module GoodJob class JobsFilter < BaseFilter def states - query = filtered_query(params.except(:state)) - { - 'scheduled' => query.scheduled.count, - 'retried' => query.retried.count, - 'queued' => query.queued.count, - 'running' => query.running.count, - 'succeeded' => query.succeeded.count, - 'discarded' => query.discarded.count, - } + @_states ||= begin + query = filtered_query(params.except(:state)) + { + 'scheduled' => query.scheduled.count, + 'retried' => query.retried.count, + 'queued' => query.queued.count, + 'running' => query.running.count, + 'succeeded' => query.succeeded.count, + 'discarded' => query.discarded.count, + } + end end def filtered_query(filter_params = params) @@ -42,13 +44,13 @@ def filtered_query(filter_params = params) end def filtered_count - filtered_query.unscope(:select).count + @_filtered_count ||= filtered_query.unscope(:select).count end private def query_for_records - filtered_query.includes(:executions).includes_advisory_locks + filtered_query.includes_advisory_locks end def default_base_query diff --git a/app/views/good_job/jobs/_table.erb b/app/views/good_job/jobs/_table.erb index 2f88ab8ed..5df6f9931 100644 --- a/app/views/good_job/jobs/_table.erb +++ b/app/views/good_job/jobs/_table.erb @@ -82,7 +82,7 @@ bs_toggle: "popover", bs_trigger: "hover focus click", bs_placement: "bottom", - bs_content: job.recent_error + bs_content: job.error.presence || job.serialized_params['exception_executions'].to_s, } %> <% else %> <%= job.executions_count %>