Skip to content

Commit

Permalink
Refs #38072 - bootc api pagination data + UI-friendly data re-org
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Dec 17, 2024
1 parent 7bbefa8 commit fb3bd87
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ class Api::V2::HostBootcImagesController < Api::V2::ApiController
param :per_page, :number, :desc => N_("Number of results per page to return")
def bootc_images
bootc_image_map = bootc_host_image_map
page = params[:page] || 1
per_page = params[:per_page] || Setting[:entries_per_page]
paged_results = bootc_image_map.to_a.paginate(page: page, per_page: per_page)
render json: { total: bootc_image_map.size, bootc_images: paged_results }
page = params[:page].to_i || 1
per_page = params[:per_page].to_i || Setting[:entries_per_page]
paged_images = bootc_image_map.to_a.paginate(page: page, per_page: per_page)
results = paged_images.collect { |image| { image_name: image[0], digests: image[1] } }
render json: { total: bootc_image_map.size, page: page, per_page: per_page, subtotal: bootc_image_map.size, results: results}
end

private
Expand Down

0 comments on commit fb3bd87

Please sign in to comment.