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: make `Journable::WithHistoricAttributes.wrap` detect single object and multiple objects

Sebastian Fiedlschuster311d6584899c
diff --git a/app/models/journable/with_historic_attributes.rb b/app/models/journable/with_historic_attributes.rb
index f8045a45452..357c9d0cb1e 100644
--- a/app/models/journable/with_historic_attributes.rb
+++ b/app/models/journable/with_historic_attributes.rb
@@ -89,8 +89,13 @@ class Journable::WithHistoricAttributes < SimpleDelegator
self.matches_query_at_timestamps = []
end
- def self.wrap(journable, timestamps: nil, query: nil, include_only_changed_attributes: false)
- wrap_one(journable, timestamps:, query:, include_only_changed_attributes:)
+ def self.wrap(journable_or_journables, timestamps: nil, query: nil, include_only_changed_attributes: false)
+ case journable_or_journables
+ when Array, ActiveRecord::Relation
+ wrap_multiple(journable_or_journables, timestamps:, query:, include_only_changed_attributes:)
+ else
+ wrap_one(journable_or_journables, timestamps:, query:, include_only_changed_attributes:)
+ end
end
def self.wrap_one(journable, timestamps: nil, query: nil, include_only_changed_attributes: false)
diff --git a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
index c5390dd915c..4eeb4702542 100644
--- a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
+++ b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
@@ -51,7 +51,7 @@ module API::V3::WorkPackages::EagerLoading
def work_packages_with_historic_attributes
@work_packages_with_historic_attributes ||= begin
@timestamps ||= @query.try(:timestamps) || []
- Journable::WithHistoricAttributes.wrap_multiple(work_packages, timestamps: @timestamps, query: @query) # TODO: rename wrap to wrap_one, wrap_multiple to wrap
+ Journable::WithHistoricAttributes.wrap_multiple(work_packages, timestamps: @timestamps, query: @query)
end
end