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 scope in Queries::Projects::Orders::CustomFieldOrder
Ivan Kuchin45908205357c
diff --git a/app/models/queries/projects/orders/custom_field_order.rb b/app/models/queries/projects/orders/custom_field_order.rbindex e11575ab3d7..e0cbb3f1e37 100644--- a/app/models/queries/projects/orders/custom_field_order.rb+++ b/app/models/queries/projects/orders/custom_field_order.rb@@ -29,27 +29,25 @@class Queries::Projects::Orders::CustomFieldOrder < Queries::Orders::Baseself.model = Project.all- EXCLUDED_CUSTOM_FIELD_TYPES = %w(text)- KEY_FORMAT = /cf_(\d+)/+ EXCLUDED_CUSTOM_FIELD_TYPES = %w[text].freezevalidates :custom_field, presence: { message: I18n.t(:"activerecord.errors.messages.does_not_exist") }def self.keyvalid_ids = RequestStore.fetch(:custom_sortable_project_custom_fields) do- ProjectCustomField.where.not(field_format: EXCLUDED_CUSTOM_FIELD_TYPES).visible.pluck(:id)+ scope.pluck(:id)end/\Acf_(#{valid_ids.join('|')})\z/end+ def self.scope+ ProjectCustomField.where.not(field_format: EXCLUDED_CUSTOM_FIELD_TYPES).visible+ end+def custom_field@custom_field ||= begin- id = KEY_FORMAT.match(attribute)[1]-- ProjectCustomField- .where.not(field_format: EXCLUDED_CUSTOM_FIELD_TYPES)- .visible- .find_by(id:)+ self.class.scope.find_by(id: attribute[/\Acf_(\d+)\z/, 1])endend