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

simplify filtering of changes

Ivan Kuchin3325209604fa
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
index eeeb0783418..56909c6bbd4 100644
--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
@@ -90,28 +90,13 @@ module Acts::Journalized
merged_journals = merge_reference_journals_by_id(original_journals, changed_journals, key.to_s, value.to_s)
- changes = added_references(merged_journals)
- .merge(removed_references(merged_journals))
- .merge(changed_references(merged_journals))
+ changes = merged_journals.reject do |_, (old_value, new_value)|
+ old_value.to_s.strip == new_value.to_s.strip
+ end
to_changes_format(changes, association_name.to_s)
end
- def added_references(merged_references)
- merged_references
- .select { |_, (old_value, new_value)| old_value.to_s.empty? && new_value.present? }
- end
-
- def removed_references(merged_references)
- merged_references
- .select { |_, (old_value, new_value)| old_value.present? && new_value.to_s.empty? }
- end
-
- def changed_references(merged_references)
- merged_references
- .select { |_, (old_value, new_value)| old_value.present? && new_value.present? && old_value.strip != new_value.strip }
- end
-
def to_changes_format(references, key)
references.each_with_object({}) do |(id, (old_value, new_value)), result|
result["#{key}_#{id}"] = [old_value, new_value]