Skip to content

Commit 4d17572

Browse files
committed
Fixes #38891 - Refactor @subtotal assignment for API hosts action
1 parent 0ecd960 commit 4d17572

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

app/controllers/api/v2/job_invocations_controller.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +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
120+
require 'pry-byebug'; binding.pry;
120121
@hosts = @hosts.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page], :per_page => params[:per_page])
121-
if params[:awaiting]
122-
@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
126-
end
122+
@hosts = @hosts.select { |host| @host_statuses[host.id] == 'N/A' } if params[:awaiting]
123+
@subtotal = @hosts.try(:count).to_i
127124
render :hosts, :layout => 'api/v2/layouts/index_layout'
128125
end
129126

0 commit comments

Comments
 (0)