mirror of
https://github.com/discourse/discourse.git
synced 2025-05-01 23:14:33 +08:00
topic reply count resync for each new post
This commit is contained in:
parent
efa99eb242
commit
a7f92ec0c1
@ -487,6 +487,19 @@ class User < ActiveRecord::Base
|
|||||||
group('trust_level').count
|
group('trust_level').count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_topic_reply_count
|
||||||
|
topic_reply_count =
|
||||||
|
Topic
|
||||||
|
.where(['id in (
|
||||||
|
SELECT topic_id FROM posts p
|
||||||
|
JOIN topics t2 ON t2.id = p.topic_id
|
||||||
|
WHERE deleted_at IS NULL AND
|
||||||
|
t2.user_id <> p.user_id AND
|
||||||
|
p.user_id = ?
|
||||||
|
)', self.id])
|
||||||
|
.count
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def cook
|
def cook
|
||||||
@ -567,4 +580,5 @@ class User < ActiveRecord::Base
|
|||||||
errors.add(:password, "must be 6 letters or longer")
|
errors.add(:password, "must be 6 letters or longer")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -117,7 +117,7 @@ class PostCreator
|
|||||||
|
|
||||||
|
|
||||||
if @user.id != topic.user_id
|
if @user.id != topic.user_id
|
||||||
@user.topic_reply_count += 1
|
@user.update_topic_reply_count
|
||||||
end
|
end
|
||||||
|
|
||||||
@user.last_posted_at = post.created_at
|
@user.last_posted_at = post.created_at
|
||||||
|
Loading…
x
Reference in New Issue
Block a user