fixes #1614
This commit is contained in:
@@ -90,16 +90,17 @@ class ForumPost < ActiveRecord::Base
|
|||||||
|
|
||||||
def update_topic_updated_at_on_create
|
def update_topic_updated_at_on_create
|
||||||
if topic
|
if topic
|
||||||
topic.updater_id = CurrentUser.id
|
# need to do this to bypass the topic's original post from getting touched
|
||||||
topic.response_count = topic.response_count + 1
|
ForumTopic.update_all(["updater_id = ?, response_count = response_count + 1, updated_at = ?", CurrentUser.id, Time.now], {:id => topic.id})
|
||||||
topic.save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_topic_updated_at_on_destroy
|
def update_topic_updated_at_on_destroy
|
||||||
max = ForumPost.where(:topic_id => topic.id).maximum(:updated_at)
|
max = ForumPost.where(:topic_id => topic.id).maximum(:updated_at)
|
||||||
if max
|
if max
|
||||||
topic.update_column(:updated_at, max)
|
ForumTopic.update_all(["response_count = response_count - 1, updated_at = ?", max], {:id => topic.id})
|
||||||
|
else
|
||||||
|
ForumTopic.update_all(["response_count = response_count - 1"], {:id => topic.id})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user