Skip to content

Commit

Permalink
(fix) Refactor AR PowerOfAttorneyRequestController includes for impro…
Browse files Browse the repository at this point in the history
…ved 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
  • Loading branch information
ojbucao authored and nihil2501 committed Dec 21, 2024
1 parent c6e4481 commit ce1dea1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce1dea1

Please sign in to comment.