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

avoid AR dirty checking showing changes on historic attributes eager loading

ulfertsd4b81c7f4b8d
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 0ddf182ad04..bb986602615 100644
--- a/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
+++ b/lib/api/v3/work_packages/eager_loading/historic_attributes.rb
@@ -62,11 +62,8 @@ module API::V3::WorkPackages::EagerLoading
private
def set_attributes_at_timestamp(work_package, source, timestamp, override_current: false)
- work_package.attributes = source.attributes.except('timestamp') if override_current
- work_package.matches_filters_at_timestamp = source.matches_query_filters_at_timestamps.include?(timestamp)
- work_package.exists_at_timestamp = source.exists_at_timestamps.include?(timestamp)
- work_package.attributes_changed_to_baseline = source.changed_at_timestamp(timestamp)
- work_package.with_query = source.query.present?
+ override_attributes(work_package, source) if override_current
+ set_timestamp_attributes(work_package, source, timestamp)
end
def work_packages_with_historic_attributes
@@ -81,6 +78,18 @@ module API::V3::WorkPackages::EagerLoading
def timestamps
@timestamps ||= query.try(:timestamps) || []
end
+
+ def override_attributes(work_package, source)
+ work_package.attributes = source.attributes.except('timestamp')
+ work_package.clear_changes_information
+ end
+
+ def set_timestamp_attributes(work_package, source, timestamp)
+ work_package.matches_filters_at_timestamp = source.matches_query_filters_at_timestamps.include?(timestamp)
+ work_package.exists_at_timestamp = source.exists_at_timestamps.include?(timestamp)
+ work_package.attributes_changed_to_baseline = source.changed_at_timestamp(timestamp)
+ work_package.with_query = source.query.present?
+ end
end
module HistoricAttributesAccessors