mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-08 07:40:08 +09:00
Render the boosts a message has preloaded instead of querying them again
Pages of messages load them with_presentation, which preloads each message's boosts with their boosters and avatars, but the boosts partial asked for message.boosts.ordered: a new query for every message, and the preloaded boosts went unused. Sort the preloaded boosts in Ruby. The boosts frame, whose message comes without them, still queries them in order with their boosters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0142qgjggdJ2KDdGk7RF9Xm9
This commit is contained in:
@@ -53,6 +53,20 @@ class MessagesCachingTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test "messages render their preloaded boosts in order without querying them again" do
|
||||
earlier = messages(:fourth).boosts.create! booster: users(:jason), content: "🥇", created_at: 1.day.ago
|
||||
in_order = [ dom_id(earlier), dom_id(boosts(:fourth_by_bender)) ]
|
||||
|
||||
assert_no_queries_match(/ORDER BY "boosts"/) do
|
||||
get room_messages_url(rooms(:watercooler))
|
||||
end
|
||||
assert_response :success
|
||||
assert_equal in_order, css_select("##{dom_id(messages(:fourth), :boosts)} .boost").map { it["id"] }
|
||||
|
||||
get message_boosts_url(messages(:fourth))
|
||||
assert_equal in_order, css_select("##{dom_id(messages(:fourth), :boosts)} .boost").map { it["id"] }
|
||||
end
|
||||
|
||||
private
|
||||
def with_memory_cache
|
||||
old_cache = Rails.cache
|
||||
|
||||
Reference in New Issue
Block a user