mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
DEV: Move user count update for channels to ensure_consistency! (#22321)
This fixes a longstanding TODO to move the contents of the UpdateUserCountsForChannels job to the ensure_consistency! method of Chat::Channel, which runs every 15 mins as part of periodical updates. This commit also addresses the performance issue of the original, where we would fetch all channels and do an individual query to get the count and update the count of each one. Now we do it all in one query, and only publish the changed channels to the UI.
This commit is contained in:
@ -170,7 +170,7 @@ describe Chat do
|
||||
user_2.user_chat_channel_memberships.create!(chat_channel: chat_channel, following: true)
|
||||
user_3.user_chat_channel_memberships.create!(chat_channel: chat_channel, following: true)
|
||||
user_4.user_chat_channel_memberships.create!(chat_channel: chat_channel, following: true)
|
||||
Jobs::Chat::UpdateUserCountsForChannels.new.execute({})
|
||||
Chat::Channel.ensure_consistency!
|
||||
|
||||
expect(Oneboxer.preview(chat_url)).to match_html <<~HTML
|
||||
<aside class="onebox chat-onebox">
|
||||
|
Reference in New Issue
Block a user