Skip to content

Commit

Permalink
Fixes #33700 - Added/Not added component CVs API fix (Katello#9726)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 authored Oct 27, 2021
1 parent fcda5a1 commit 68427d8
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ def show_all
SQL
query = Katello::ContentView.readable.in_organization(@organization)
query = query&.non_composite&.non_default
component_cv_ids = Katello::ContentViewComponent.where(composite_content_view_id: @view.id).select(:content_view_id)
query = case params[:status]
when "Not added"
query.where.not(id: component_cv_ids)
when "Added"
query.where(id: component_cv_ids)
else
query
end
custom_sort = ->(sort_query) { sort_query.joins(join_query).order(order_query) }
options = { resource_class: Katello::ContentView, custom_sort: custom_sort }
collection = scoped_search(query, nil, nil, options)
collection[:results] = ComponentViewPresenter.component_presenter(@view, params[:status], views: collection[:results])
collection[:total] = get_total params[:status]
collection[:subtotal] = collection[:total]

respond_for_index(:collection => collection, :template => "index")
end

Expand Down

0 comments on commit 68427d8

Please sign in to comment.