Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDM/use filter params constant to bypass versioning #1343

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/v1/lcpe/lacs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def list
def index_params
return @index_params if defined?(@index_params)

@index_params = params.permit(:edu_lac_type_nm, :state, :lac_nm, :page, :per_page)
@index_params = params.permit(*FILTER_PARAMS)
end

def page
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/v1/lcpe_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class PreloadVersionStaleError < StandardError; end

rescue_from PreloadVersionStaleError, with: :version_invalid

FILTER_PARAMS = %i[edu_lac_type_nm state lac_nm page per_page].freeze

private

def validate_preload_version
Expand Down Expand Up @@ -35,11 +37,7 @@ def set_headers(preload_version)

# If additional filter params present, bypass versioning
def bypass_versioning?
scrubbed_params.present?
end

def scrubbed_params
params.except(:format, :controller, :action, controller_name.singularize.to_sym)
params.keys.map(&:to_sym).intersect?(FILTER_PARAMS)
end

def version_invalid
Expand Down