mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
Revert "PERF: optimise query that gathers topic tracking state"
This reverts commit 343e417a55db681db78da5121032c0e717f537a9.
This commit is contained in:
@ -20,7 +20,7 @@ describe TopicTrackingState do
|
||||
user = Fabricate(:user)
|
||||
post
|
||||
|
||||
report = TopicTrackingState.report(user.id)
|
||||
report = TopicTrackingState.report([user.id])
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
CategoryUser.create!(user_id: user.id,
|
||||
@ -30,23 +30,22 @@ describe TopicTrackingState do
|
||||
|
||||
create_post(topic_id: post.topic_id)
|
||||
|
||||
report = TopicTrackingState.report(user.id)
|
||||
report = TopicTrackingState.report([user.id])
|
||||
expect(report.length).to eq(0)
|
||||
|
||||
TopicUser.create!(user_id: user.id, topic_id: post.topic_id, last_read_post_number: 1, notification_level: 3)
|
||||
|
||||
report = TopicTrackingState.report(user.id)
|
||||
# no read state for muted categories, query is faster
|
||||
expect(report.length).to eq(0)
|
||||
report = TopicTrackingState.report([user.id])
|
||||
expect(report.length).to eq(1)
|
||||
end
|
||||
|
||||
it "correctly gets the tracking state" do
|
||||
report = TopicTrackingState.report(user.id)
|
||||
report = TopicTrackingState.report([user.id])
|
||||
expect(report.length).to eq(0)
|
||||
|
||||
post.topic.notifier.watch_topic!(post.topic.user_id)
|
||||
|
||||
report = TopicTrackingState.report(user.id)
|
||||
report = TopicTrackingState.report([user.id])
|
||||
|
||||
expect(report.length).to eq(1)
|
||||
row = report[0]
|
||||
@ -57,18 +56,15 @@ describe TopicTrackingState do
|
||||
expect(row.user_id).to eq(user.id)
|
||||
|
||||
# lets not leak out random users
|
||||
expect(TopicTrackingState.report(post.user_id)).to be_empty
|
||||
expect(TopicTrackingState.report([post.user_id])).to be_empty
|
||||
|
||||
# lets not return anything if we scope on non-existing topic
|
||||
expect(TopicTrackingState.report(user.id, post.topic_id + 1)).to be_empty
|
||||
expect(TopicTrackingState.report([user.id], post.topic_id + 1)).to be_empty
|
||||
|
||||
# when we reply the poster should have an unread row
|
||||
create_post(user: user, topic: post.topic)
|
||||
|
||||
report = TopicTrackingState.report(user.id)
|
||||
expect(report.length).to eq(0)
|
||||
|
||||
report = TopicTrackingState.report(post.user_id)
|
||||
report = TopicTrackingState.report([post.user_id, user.id])
|
||||
expect(report.length).to eq(1)
|
||||
|
||||
row = report[0]
|
||||
@ -84,7 +80,6 @@ describe TopicTrackingState do
|
||||
post.topic.category_id = category.id
|
||||
post.topic.save
|
||||
|
||||
expect(TopicTrackingState.report(post.user_id)).to be_empty
|
||||
expect(TopicTrackingState.report(user.id)).to be_empty
|
||||
expect(TopicTrackingState.report([post.user_id, user.id]).count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user