mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FIX: Display actual readers on the first post
This commit is contained in:
@ -10,7 +10,8 @@ class PostReadersController < ApplicationController
|
|||||||
|
|
||||||
readers = User
|
readers = User
|
||||||
.joins(:topic_users)
|
.joins(:topic_users)
|
||||||
.where('topic_users.topic_id = ? AND COALESCE(topic_users.last_read_post_number, 1) >= ?', post.topic_id, post.post_number)
|
.where.not(topic_users: { last_read_post_number: nil })
|
||||||
|
.where('topic_users.topic_id = ? AND topic_users.last_read_post_number >= ?', post.topic_id, post.post_number)
|
||||||
.where.not(id: [current_user.id, post.user_id])
|
.where.not(id: [current_user.id, post.user_id])
|
||||||
|
|
||||||
readers = readers.map do |r|
|
readers = readers.map do |r|
|
||||||
|
@ -65,6 +65,16 @@ describe PostReadersController do
|
|||||||
|
|
||||||
expect(reader).to be_nil
|
expect(reader).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't include users without reading progress on first post" do
|
||||||
|
@post.update(post_number: 1)
|
||||||
|
TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: nil)
|
||||||
|
|
||||||
|
get '/post_readers.json', params: { id: @post.id }
|
||||||
|
readers = JSON.parse(response.body)['post_readers']
|
||||||
|
|
||||||
|
expect(readers).to be_empty
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_reader_is_correctly_serialized(reader_data, reader, post)
|
def assert_reader_is_correctly_serialized(reader_data, reader, post)
|
||||||
|
Reference in New Issue
Block a user