diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/models/discussion.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-8ed83bb76a87aac2ee8eb7e232a630a2b534ad93.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/models/discussion.rb')
-rw-r--r-- | app/models/discussion.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb index 70aa02063cc..076d8cc280c 100644 --- a/app/models/discussion.rb +++ b/app/models/discussion.rb @@ -7,6 +7,9 @@ class Discussion include GlobalID::Identification include ResolvableDiscussion + # Bump this if we need to refresh the cached versions of discussions + CACHE_VERSION = 1 + attr_reader :notes, :context_noteable delegate :created_at, @@ -158,4 +161,19 @@ class Discussion def reply_attributes first_note.slice(:type, :noteable_type, :noteable_id, :commit_id, :discussion_id) end + + def cache_key + # Need this so cache will be invalidated when note within a discussion + # has been deleted. + notes_sha = Digest::SHA1.hexdigest(notes.map(&:id).join(':')) + + [ + CACHE_VERSION, + notes.last.latest_cached_markdown_version, + id, + notes_sha, + notes.max_by(&:updated_at).updated_at, + resolved_at + ].join(':') + end end |