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 commond code for changed_days and changed_non_working_dates
Ivan Kuchinc8bd1678b010
diff --git a/app/workers/work_packages/apply_working_days_change_job.rb b/app/workers/work_packages/apply_working_days_change_job.rbindex 8e3247ffc7a..0cf192cb492 100644--- a/app/workers/work_packages/apply_working_days_change_job.rb+++ b/app/workers/work_packages/apply_working_days_change_job.rb@@ -88,21 +88,20 @@ class WorkPackages::ApplyWorkingDaysChangeJob < ApplicationJobenddef changed_days- previous = Set.new(previous_working_days)- current = Set.new(Setting.working_days)-- # `^` is a Set method returning a new set containing elements exclusive to- # each other- (previous ^ current).index_with { |day| current.include?(day) }+ # reverse order, so new working days map to true+ change_between(previous_working_days, Setting.working_days)enddef changed_non_working_dates- previous = Set.new(previous_non_working_days)- current = Set.new(NonWorkingDay.pluck(:date))+ # reverse order, as new non working dates map to false+ change_between(NonWorkingDay.pluck(:date), previous_non_working_days)+ end++ def change_between(list_a, list_b)+ set_a = Set.new(list_a)+ set_b = Set.new(list_b)- # `^` is a Set method returning a new set containing elements exclusive to- # each other- (previous ^ current).index_with { |day| current.exclude?(day) }+ (set_a ^ set_b).index_with { set_b.include?(it) }enddef applicable_predecessors