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

use updated_at instead of created_at since journals are now reused

ulfertsff6dccb21d60
diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rb
index 5ac1ac584b8..dbd4bf49807 100644
--- a/app/services/journals/create_service.rb
+++ b/app/services/journals/create_service.rb
@@ -182,7 +182,6 @@ module Journals
journals
SET
notes = :notes,
- created_at = #{journal_timestamp_sql(notes, ':created_at')},
updated_at = #{journal_timestamp_sql(notes, ':updated_at')},
data_id = insert_data.id
FROM insert_data
@@ -193,7 +192,6 @@ module Journals
sanitize(journal_sql,
notes: notes.present? ? notes : predecessor.notes,
- created_at: journable_timestamp,
updated_at: journable_timestamp,
predecessor_id: predecessor.id)
end
@@ -533,14 +531,14 @@ module Journals
# as to avoid changing lock versions on the journables for this change
attributes = journable.send(:timestamp_attributes_for_update_in_model)
- timestamps = attributes.index_with { journal.created_at }
+ timestamps = attributes.index_with { journal.updated_at }
journable.update_columns(timestamps) if timestamps.any?
end
def aggregatable?(predecessor, notes)
predecessor.present? &&
Setting.journal_aggregation_time_minutes.to_i > 0 &&
- predecessor.created_at >= Time.zone.now - Setting.journal_aggregation_time_minutes.to_i.minutes &&
+ predecessor.updated_at >= Time.zone.now - Setting.journal_aggregation_time_minutes.to_i.minutes &&
predecessor.user_id == user.id &&
(predecessor.notes.empty? || notes.empty?)
end
diff --git a/spec/models/work_package/work_package_acts_as_journalized_spec.rb b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
index 96633db2404..cb4f4b269ec 100644
--- a/spec/models/work_package/work_package_acts_as_journalized_spec.rb
+++ b/spec/models/work_package/work_package_acts_as_journalized_spec.rb
@@ -447,11 +447,8 @@ describe WorkPackage, type: :model do
end
it 'has the timestamp of the work package update time for created_at' do
- # This seemingly unnecessary reload leads to the updated_at having the same
- # precision as the created_at of the Journal. It is database dependent, so it would work without
- # reload on PG 12 but does not work on PG 9.
- expect(work_package.journals.last.created_at)
- .to eql(work_package.reload.updated_at)
+ expect(work_package.journals.last.updated_at)
+ .to eql(work_package.updated_at)
end
end
@@ -463,11 +460,8 @@ describe WorkPackage, type: :model do
end
it 'has the timestamp of the work package update time for created_at' do
- # This seemingly unnecessary reload leads to the updated_at having the same
- # precision as the created_at of the Journal. It is database dependent, so it would work without
- # reload on PG 12 but does not work on PG 9.
- expect(work_package.journals.last.created_at)
- .to eql(work_package.reload.updated_at)
+ expect(work_package.journals.last.updated_at)
+ .to eql(work_package.updated_at)
end
end