Skip to content

Commit ae1dee6

Browse files
committed
Prepend copy dependencies instead of index insert
Sprints and buckets only need to run before the work packages, so prepending them is simpler than locating the index and inserting.
1 parent d7e352f commit ae1dee6

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

modules/backlogs/lib/open_project/backlogs/patches/copy_service_patch.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,11 @@ module OpenProject::Backlogs::Patches::CopyServicePatch
3838

3939
module ClassMethods
4040
def copy_dependencies
41-
super.tap do |dependencies|
42-
index = dependencies.index(::Projects::Copy::WorkPackagesDependentService)
43-
next unless index
44-
45-
# Both must precede the work packages so their id maps are ready when the
46-
# work packages are copied and their sprint/bucket ids remapped.
47-
dependencies.insert(index,
48-
::Projects::Copy::SprintsDependentService,
49-
::Projects::Copy::BacklogBucketsDependentService)
50-
end
41+
# Sprints and backlog buckets must precede the `WorkPackagesDependentService`
42+
# so their id maps are ready when the work packages are copied and their
43+
# sprint/bucket ids remapped.
44+
[::Projects::Copy::SprintsDependentService,
45+
::Projects::Copy::BacklogBucketsDependentService] + super
5146
end
5247
end
5348

0 commit comments

Comments
 (0)