Skip to content

Commit

Permalink
Show hosts for scheduled jobs
Browse files Browse the repository at this point in the history
Searching inside scheduled jobs doesn't really work, but at least that's
consistent with the old implementation.
  • Loading branch information
adamruzicka authored and kmalyjur committed Jan 28, 2025
1 parent f4aefaa commit 8b285cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions app/controllers/api/v2/job_invocations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ def parent_scope
def set_hosts_and_template_invocations
@pattern_template_invocations = @job_invocation.pattern_template_invocations.includes(:input_values)
@hosts = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)

unless params[:search].nil?
@hosts = @hosts.joins(:template_invocations)
.where(:template_invocations => { :job_invocation_id => @job_invocation.id})
end
@template_invocations = @job_invocation.template_invocations
.where(host: @hosts)
.includes(:input_values)
Expand Down
12 changes: 6 additions & 6 deletions webpack/JobInvocationDetail/JobInvocationHostTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ const JobInvocationHostTable = ({
filter = selectedFilter,
search = urlSearchQuery
) => {
const baseFilter = `job_invocation.id = ${id}`;
const dropdownFilterClause =
filter && filter !== 'all_statuses'
? `and job_invocation.result = ${filter}`
: '';
const searchQueryClause = search ? `and (${search})` : '';
return `${baseFilter} ${dropdownFilterClause} ${searchQueryClause}`;
? `job_invocation.result = ${filter}`
: null;
const parts = [dropdownFilterClause, search];
return parts.filter((x) => x).map((fragment) => `(${fragment}})`).join(' AND ');
};

const defaultParams = { search: constructFilter() };
const filter = constructFilter();
const defaultParams = filter != '' ? { search: filter } : {};
if (urlPage) defaultParams.page = Number(urlPage);
if (urlPerPage) defaultParams.per_page = Number(urlPerPage);
const [expandedHost, setExpandedHost] = useState([]);
Expand Down

0 comments on commit 8b285cb

Please sign in to comment.