Skip to content

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

refactor method for producing a hash with differenc between two lists

Ivan Kuchin3e8763173bad
diff --git a/app/workers/work_packages/apply_working_days_change_job.rb b/app/workers/work_packages/apply_working_days_change_job.rb
index 0cf192cb492..9e77aaa5775 100644
--- a/app/workers/work_packages/apply_working_days_change_job.rb
+++ b/app/workers/work_packages/apply_working_days_change_job.rb
@@ -98,10 +98,10 @@ class WorkPackages::ApplyWorkingDaysChangeJob < ApplicationJob
end
def change_between(list_a, list_b)
- set_a = Set.new(list_a)
- set_b = Set.new(list_b)
+ deleted = (list_a - list_b).index_with(false)
+ added = (list_b - list_a).index_with(true)
- (set_a ^ set_b).index_with { set_b.include?(it) }
+ deleted.merge(added)
end
def applicable_predecessors