diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 15:08:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-12 15:08:50 +0300 |
commit | 47bb4281f0b12f158923f8a1e5691c7a4be2f2f6 (patch) | |
tree | 319d236945ce62673cab2fdcc5331e79ef0c01ba /app/models/note.rb | |
parent | 2e3f13a01a2833f85fb2201a245205b8e9d0ca9a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index b7623eae09f..3d2ac69a2ab 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -509,7 +509,15 @@ class Note < ApplicationRecord # Instead of calling touch which is throttled via ThrottledTouch concern, # we bump the updated_at column directly. This also prevents executing # after_commit callbacks that we don't need. - update_column(:updated_at, Time.current) + attributes_to_update = { updated_at: Time.current } + + # Notes that were edited before the `last_edited_at` column was added, fall back to `updated_at` for the edit time. + # We copy this over to the correct column so we don't erroneously change the edit timestamp. + if updated_by_id.present? && read_attribute(:last_edited_at).blank? + attributes_to_update[:last_edited_at] = updated_at + end + + update_columns(attributes_to_update) end def expire_etag_cache |