Skip to content

Commit

Permalink
Don't load all Executions on Jobs Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Feb 28, 2023
1 parent 357dd32 commit ce92c21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions app/filters/good_job/jobs_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/good_job/jobs/_table.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<span class="badge bg-secondary bg-opacity-50 rounded-pill"><%= job.executions_count %></span>
Expand Down

0 comments on commit ce92c21

Please sign in to comment.