PERF: Reduce overhead from chat message excerpt (#26712)

This change moves the chat message excerpt into a new database column (string) on the chat_messages table.

As part of this change, we will now set the excerpt within the `Chat::CreateMessage` service, and update it within the `Chat::UpdateMessage` service.
This commit is contained in:
David Battersby
2024-04-25 20:29:00 +08:00
committed by GitHub
parent 14fc029a30
commit c62d3610c6
19 changed files with 84 additions and 41 deletions

View File

@ -102,20 +102,12 @@ RSpec.describe "Outgoing chat webhooks" do
context "for a category channel" do
fab!(:category)
fab!(:chat_channel) { Fabricate(:category_channel, chatable: category) }
fab!(:chat_message) { Fabricate(:chat_message, chat_channel: chat_channel, user: user1) }
before do
[user1, user2].each do |user|
Chat::UserChatChannelMembership.create(
user: user,
chat_channel: chat_channel,
following: true,
)
end
sign_in(user1)
fab!(:chat_message) do
Fabricate(:chat_message, use_service: true, chat_channel: chat_channel, user: user1)
end
before { sign_in(user1) }
it "triggers a webhook when a chat message is created" do
post "/chat/#{chat_channel.id}.json", params: { message: message_content }
@ -175,7 +167,12 @@ RSpec.describe "Outgoing chat webhooks" do
fab!(:direct_message) { Fabricate(:direct_message, users: [user1, user2]) }
fab!(:direct_message_channel) { Fabricate(:direct_message_channel, chatable: direct_message) }
fab!(:chat_message) do
Fabricate(:chat_message, chat_channel: direct_message_channel, user: user1)
Fabricate(
:chat_message,
use_service: true,
chat_channel: direct_message_channel,
user: user1,
)
end
before { sign_in(user1) }