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

baseline api: move eager-loading-wrapper options assignment into base initializer

Sebastian Fiedlschuster043e13a6dc22
diff --git a/lib/api/v3/work_packages/eager_loading/base.rb b/lib/api/v3/work_packages/eager_loading/base.rb
index bd1a107d1ff..f60992e6072 100644
--- a/lib/api/v3/work_packages/eager_loading/base.rb
+++ b/lib/api/v3/work_packages/eager_loading/base.rb
@@ -31,8 +31,11 @@ module API
module WorkPackages
module EagerLoading
class Base < SimpleDelegator
- def initialize(work_packages)
+ def initialize(work_packages, **options)
self.work_packages = work_packages
+ options.each do |key, value|
+ send("#{key}=", value) if respond_to?("#{key}=")
+ end
end
def apply(_work_package)
diff --git a/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb b/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb
index d5cbb52059e..4f3b4dad4c2 100644
--- a/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb
+++ b/lib/api/v3/work_packages/work_package_eager_loading_wrapper.rb
@@ -55,16 +55,13 @@ module API
def wrap_and_apply(work_packages, container_classes, timestamps:, query:)
containers = container_classes
- .map { |klass| klass.new(work_packages) }
+ .map { |klass| klass.new(work_packages, timestamps:, query:) }
work_packages = work_packages.map do |work_package|
new(work_package)
end
containers.each do |container|
- container.timestamps = timestamps if container.respond_to?(:timestamps=)
- container.query = query if container.respond_to?(:query=)
-
work_packages.each do |work_package|
container.apply(work_package)
end