Skip to content

Commit 38a2241

Browse files
committed
Fixes #38891 - Refactor @subtotal assignment for API hosts action
1 parent 41b8dee commit 38a2241

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/controllers/api/v2/job_invocations_controller.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,11 @@ def output
116116
def hosts
117117
set_hosts_and_template_invocations
118118
set_statuses_and_smart_proxies
119-
@total = @job_invocation.targeting.hosts.size
119+
@total = @hosts.size
120120
@hosts = @hosts.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page], :per_page => params[:per_page])
121+
@subtotal = @hosts.total_entries
121122
if params[:awaiting]
122123
@hosts = @hosts.select { |host| @host_statuses[host.id] == 'N/A' }
123-
@subtotal = @hosts.size
124-
else
125-
@subtotal = @hosts.respond_to?(:total_entries) ? @hosts.total_entries : @hosts.sizes
126124
end
127125
render :hosts, :layout => 'api/v2/layouts/index_layout'
128126
end
@@ -303,7 +301,7 @@ def set_hosts_and_template_invocations
303301
@pattern_template_invocations = @job_invocation.pattern_template_invocations.includes(:input_values)
304302
@hosts = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)
305303

306-
unless params[:search].nil?
304+
if params[:search].present?
307305
@hosts = @hosts.joins(:template_invocations)
308306
.where(:template_invocations => { :job_invocation_id => @job_invocation.id})
309307
end

0 commit comments

Comments
 (0)