OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix rubocop warning: Assignment Branch Condition size for calculate_resulting_params is too high
Eric Guo14865f580092
diff --git a/app/services/api/v3/work_package_collection_from_query_service.rb b/app/services/api/v3/work_package_collection_from_query_service.rbindex 7623995781d..886b9298765 100644--- a/app/services/api/v3/work_package_collection_from_query_service.rb+++ b/app/services/api/v3/work_package_collection_from_query_service.rb@@ -77,22 +77,11 @@ module APIenddef calculate_resulting_params(provided_params)- calculate_default_params- .merge(provided_params.symbolize_keys.slice(:offset, :pageSize))- .tap do |params|- if query.manually_sorted?- params[:query_id] = query.id- params[:offset] = 1- # Force the setting value in all cases except when 0 is requested explicitly. Fetching with pageSize = 0- # is done for performance reasons to simply get the query without the results.- params[:pageSize] = pageSizeParam(params) == 0 ? pageSizeParam(params) : Setting.forced_single_page_size- else- params[:offset] = to_i_or_nil(params[:offset])- params[:pageSize] = pageSizeParam(params)- end-- params[:select] = nested_from_csv(provided_params["select"]) if provided_params["select"]- end+ params = calculate_default_params+ .merge(provided_params.symbolize_keys.slice(:offset, :pageSize))+ handle_offset_paging_params(params)+ handle_select_params(params, provided_params)+ paramsenddef calculate_default_params@@ -174,6 +163,23 @@ module APIendend+ def handle_offset_paging_params(params)+ if query.manually_sorted?+ params[:query_id] = query.id+ params[:offset] = 1+ # Force the setting value in all cases except when 0 is requested explicitly. Fetching with pageSize = 0+ # is done for performance reasons to simply get the query without the results.+ params[:pageSize] = pageSizeParam(params) == 0 ? pageSizeParam(params) : Setting.forced_single_page_size+ else+ params[:offset] = to_i_or_nil(params[:offset])+ params[:pageSize] = pageSizeParam(params)+ end+ end++ def handle_select_params(params, provided_params)+ params[:select] = nested_from_csv(provided_params["select"]) if provided_params["select"]+ end+def to_i_or_nil(value)value ? value.to_i : nilend