Commit ad13cee7 authored by mo khan's avatar mo khan

Inline filter params

parent 4c60f5b2
...@@ -61,18 +61,15 @@ module Projects ...@@ -61,18 +61,15 @@ module Projects
params.require(:software_license_policy).permit(:software_license_id, :spdx_identifier, :classification) params.require(:software_license_policy).permit(:software_license_id, :spdx_identifier, :classification)
end end
def filter_params
params.permit(:detected, classification: [])
end
def render_error_for(result) def render_error_for(result)
render json: { errors: result[:message].as_json }, status: result.fetch(:http_status, :unprocessable_entity) render json: { errors: result[:message].as_json }, status: result.fetch(:http_status, :unprocessable_entity)
end end
def matching_policies_from(license_compliance) def matching_policies_from(license_compliance)
filters = params.permit(:detected, classification: [])
license_compliance.find_policies( license_compliance.find_policies(
detected_only: filter_params[:detected].present?, detected_only: filters[:detected].present?,
classification: Array(filter_params[:classification] || []) classification: filters[:classification]
) )
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment