mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-09 16:20:09 +09:00
Leave members who are unread already out of a new message's update
Every message rewrote the row of every disconnected member of the room, including the ones who were unread already and stay unread. Open rooms take in the whole account, so in steady state that is every member on every message: 325 WAL pages per post at 10,000 members, against 16 when only the members who had read the room are written. Directs keep touching all their members: a direct's sidebar row is cached by its membership and carries the room's recency, so it has to be refreshed on every message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017dFSDHrgrLoBELwjV3Qunq
This commit is contained in:
@@ -25,6 +25,20 @@ class RoomTest < ActiveSupport::TestCase
|
||||
assert room.users.include?(users(:david))
|
||||
end
|
||||
|
||||
test "a new message marks unread the members who had read the room and leaves the unread ones as they were" do
|
||||
room = rooms(:watercooler)
|
||||
reader = memberships(:jason_watercooler)
|
||||
behind = memberships(:bender_watercooler)
|
||||
behind.update_columns unread_at: 1.hour.ago, updated_at: 1.hour.ago
|
||||
behind_before = behind.reload.attributes.slice("unread_at", "updated_at")
|
||||
|
||||
message = room.messages.create! creator: users(:david), body: "Hello", client_message_id: "unread-once"
|
||||
|
||||
assert_equal message.created_at, reader.reload.unread_at
|
||||
assert_equal behind_before, behind.reload.attributes.slice("unread_at", "updated_at")
|
||||
assert_not memberships(:david_watercooler).reload.unread?
|
||||
end
|
||||
|
||||
test "type" do
|
||||
assert Rooms::Open.new.open?
|
||||
assert_not Rooms::Open.new.direct?
|
||||
|
||||
Reference in New Issue
Block a user