Skip to content

Commit 6f28bda

Browse files
committed
added Comment#last_activity_at and ensured CommentThread#last_activity_at takes that into account
1 parent 7c3c26e commit 6f28bda

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

app/models/comment.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ class Comment < ApplicationRecord
1919

2020
validate :content_length
2121

22+
# Gets last activity date and time on the comment
23+
# @return [DateTime] last activity date and time
24+
def last_activity_at
25+
[created_at, updated_at].compact.max
26+
end
27+
2228
def root
2329
# If parent_question is nil, the comment is already on a question, so we can just return post.
2430
parent_question || post

app/models/comment_thread.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def can_access?(user)
5252
# Gets last activity date and time on the thread
5353
# @return [DateTime] last activity date and time
5454
def last_activity_at
55-
[created_at, locked_at, updated_at].compact.max
55+
last_comment_activity_at = comments.map(&:last_activity_at).max
56+
[created_at, locked_at, updated_at, last_comment_activity_at].compact.max
5657
end
5758

5859
# Gets a list of user IDs who should be pingable in the thread.

0 commit comments

Comments
 (0)