From ce1dea1c05d5aa7d6c5061870d1c7d52722e5652 Mon Sep 17 00:00:00 2001 From: OJ Bucao Date: Fri, 20 Dec 2024 13:54:02 -0800 Subject: [PATCH] (fix) Refactor AR PowerOfAttorneyRequestController includes for improved query performance - Updated `includes` to reference `resolving` instead of just `resolution` - Added a limit of 100 records in the `index` action to optimize data retrieval --- .../v0/power_of_attorney_requests_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb index f8387180711..2f0dc0a512a 100644 --- a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb +++ b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/power_of_attorney_requests_controller.rb @@ -4,12 +4,12 @@ module AccreditedRepresentativePortal module V0 class PowerOfAttorneyRequestsController < ApplicationController def index - poa_requests = PowerOfAttorneyRequest.includes(:resolution) + poa_requests = PowerOfAttorneyRequest.includes(resolution: :resolving).limit(100) render json: PowerOfAttorneyRequestSerializer.new(poa_requests).serializable_hash, status: :ok end def show - poa_request = PowerOfAttorneyRequest.includes(:resolution).find(params[:id]) + poa_request = PowerOfAttorneyRequest.includes(resolution: :resolving).find(params[:id]) render json: PowerOfAttorneyRequestSerializer.new(poa_request).serializable_hash, status: :ok rescue ActiveRecord::RecordNotFound render json: { error: 'Record not found' }, status: :not_found