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 Projects::Phases::ApplyWorkingDaysChangeJob methods

Dombi Attila28cd76c40eb5
diff --git a/app/workers/projects/phases/apply_working_days_change_job.rb b/app/workers/projects/phases/apply_working_days_change_job.rb
index 86c2b4f29c4..2bbbbccbab6 100644
--- a/app/workers/projects/phases/apply_working_days_change_job.rb
+++ b/app/workers/projects/phases/apply_working_days_change_job.rb
@@ -33,14 +33,15 @@ class Projects::Phases::ApplyWorkingDaysChangeJob < ApplyWorkingDaysChangeJobBas
def apply_working_days_change
Project.where(id: applicable_phases.select(:project_id)).find_each do |project|
- available_phases = project.available_phases.to_a
- phase = available_phases.find(&:start_date?)
- from = phase&.start_date
+ phases = project.available_phases.drop_while { !it.start_date? }
+ from = phases.first&.start_date
next unless from
- phases = available_phases.filter { it.position >= phase.position }
+ ProjectPhases::RescheduleService.new(user: User.current, project:).call(phases:, from:)
- reschedule_project_phases(project:, phases:, from:)
+ project.journal_cause = journal_cause
+
+ project.touch_and_save_journals
end
end
@@ -52,12 +53,4 @@ class Projects::Phases::ApplyWorkingDaysChangeJob < ApplyWorkingDaysChangeJobBas
.active
.covering_dates_or_days_of_week(days_of_week:, dates:)
end
-
- def reschedule_project_phases(project:, phases:, from:)
- ProjectPhases::RescheduleService.new(user: User.current, project:).call(phases:, from:)
-
- project.journal_cause = journal_cause
-
- project.touch_and_save_journals
- end
end