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
extract duplicate listing into constants
ulfertscbe92dfb7958
diff --git a/app/services/api/v3/parse_query_params_service.rb b/app/services/api/v3/parse_query_params_service.rbindex 603c12b9785..bc474d2d2b5 100644--- a/app/services/api/v3/parse_query_params_service.rb+++ b/app/services/api/v3/parse_query_params_service.rb@@ -29,6 +29,9 @@module APImodule V3class ParseQueryParamsService+ KEYS_GROUP_BY = %i(group_by groupBy g).freeze+ KEYS_COLUMNS = %i(columns c column_names columns[]).freeze+def call(params)json_parsed = json_parsed_params(params)return json_parsed unless json_parsed.success?@@ -79,9 +82,9 @@ module API# Group will be set to nil if parameter exists but set to empty string ('')def group_by_from_params(params)- return nil unless params_exist?(params, %i(group_by groupBy g))+ return nil unless params_exist?(params, KEYS_GROUP_BY)- attribute = params[:group_by] || params[:groupBy] || params[:g]+ attribute = params_value(params, KEYS_GROUP_BY)if attribute.present?convert_attribute attributeend@@ -129,7 +132,7 @@ module APIenddef columns_from_params(params)- columns = params[:columns] || params[:c] || params[:column_names] || params[:'columns[]']+ columns = params_value(params, KEYS_COLUMNS)return unless columns@@ -205,6 +208,10 @@ module APIunsafe_params(params).detect { |k, _| symbols.include? k.to_sym }end+ def params_value(params, symbols)+ params.slice(*symbols).first&.last+ end+### Access the parameters as a hash, which has been deprecateddef unsafe_params(params)@@ -221,7 +228,8 @@ module APIenddef group_by_empty?(params)- params_exist?(params, %i(group_by groupBy g)) && !(params[:group_by] || params[:groupBy] || params[:g]).present?+ params_exist?(params, KEYS_GROUP_BY) &&+ !params_value(params, KEYS_GROUP_BY).present?endendend