UX/PERF: Update readers count when a post from another user is read. Don't fetch the post data again just to update the count. (#8078)

This commit is contained in:
Roman Rizzi
2019-09-08 22:29:15 -03:00
committed by Sam
parent d17425cbb8
commit 7d5f3c1338
7 changed files with 28 additions and 30 deletions

View File

@@ -170,6 +170,11 @@ class Post < ActiveRecord::Base
end
end
def readers_count
read_count = reads - 1 # Excludes poster
read_count < 0 ? 0 : read_count
end
def publish_change_to_clients!(type, opts = {})
# special failsafe for posts missing topics consistency checks should fix,
# but message is safe to skip