From fb3bd87cd994353014bcc2823bc3e672214a3d35 Mon Sep 17 00:00:00 2001 From: Ian Ballou Date: Tue, 17 Dec 2024 17:42:06 +0000 Subject: [PATCH] Refs #38072 - bootc api pagination data + UI-friendly data re-org --- .../katello/api/v2/host_bootc_images_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/katello/api/v2/host_bootc_images_controller.rb b/app/controllers/katello/api/v2/host_bootc_images_controller.rb index ee8f492fa90..545e511bc7b 100644 --- a/app/controllers/katello/api/v2/host_bootc_images_controller.rb +++ b/app/controllers/katello/api/v2/host_bootc_images_controller.rb @@ -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