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
refactor: Remove unused methods about leaves
Christophe Bliardea7fe80eaad0
diff --git a/app/services/work_packages/update_ancestors/loader.rb b/app/services/work_packages/update_ancestors/loader.rbindex 43530105023..bebb80880e2 100644--- a/app/services/work_packages/update_ancestors/loader.rb+++ b/app/services/work_packages/update_ancestors/loader.rb@@ -40,7 +40,7 @@ class WorkPackages::UpdateAncestors::Loaderdef descendants_of(queried_work_package)@descendants ||= Hash.new do |hash, wp|- hash[wp] = replaced_related_of(wp, :descendants)+ hash[wp] = replaced_related_descendants(wp)end@descendants[queried_work_package]@@ -72,7 +72,7 @@ class WorkPackages::UpdateAncestors::Loaderendend- # Replace descendants/leaves by ancestors if they are the same.+ # Replace descendants by ancestors if they are the same.# This can e.g. be the case in scenario of# grandparent# |@@ -84,31 +84,27 @@ class WorkPackages::UpdateAncestors::Loader# Then grandparent and parent are already in ancestors.# Parent might be modified during the UpdateAncestorsService run,# and the descendants of grandparent need to have the updated value.- def replaced_related_of(queried_work_package, relation_type)- related_of(queried_work_package, relation_type).map do |leaf|+ def replaced_related_descendants(queried_work_package)+ related_descendants(queried_work_package).map do |leaf|if work_package.id == leaf.idwork_packageelsif (ancestor = ancestors.detect { |a| a.id == leaf.id })ancestorelse- yield leaf if block_given?leafendendend- def related_of(queried_work_package, relation_type)+ def related_descendants(queried_work_package)scope = queried_work_package- .send(relation_type)+ .descendants.where.not(id: queried_work_package.id)- if send(:"#{relation_type}_joins")- scope = scope.joins(send(:"#{relation_type}_joins"))- end-+ attributes = selected_descendants_attributesscope- .pluck(*send(:"selected_#{relation_type}_attributes"))- .map { |p| LoaderStruct.new(send(:"selected_#{relation_type}_attributes").zip(p).to_h) }+ .pluck(*attributes)+ .map { |p| LoaderStruct.new(attributes.zip(p).to_h) }end# Returns the current ancestors sorted by distance (called generations in the table)@@ -130,19 +126,7 @@ class WorkPackages::UpdateAncestors::Loaderdef selected_descendants_attributes# By having the id in here, we can avoid DISTINCT queries squashing duplicate values- %i(id estimated_hours parent_id schedule_manually ignore_non_working_days remaining_hours)- end-- def descendants_joins- nil- end-- def selected_leaves_attributes- %i(id done_ratio derived_estimated_hours estimated_hours is_closed remaining_hours derived_remaining_hours)- end-- def leaves_joins- :status+ %i[id estimated_hours parent_id schedule_manually ignore_non_working_days remaining_hours]end##@@ -165,7 +149,7 @@ class WorkPackages::UpdateAncestors::Loaderprevious_parent_changes = previous[:parent_id] || previous[:parent]- previous_parent_changes ? previous_parent_changes.first : nil+ previous_parent_changes&.firstendclass LoaderStruct < Hashie::Mash; end