mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add messages_count to ChatChannel table (#19295)
This commit adds the messages_count column for ChatChannel messages, which is the number of not-deleted messages in the channel. This is not updated every time a message is created or deleted in a channel, so it should not be displayed in the UI. It is updated eventually via Jobs::ChatPeriodicalUpdates, which will have additional functions in future after being introduced here. Also update these counts for existing channels in a post migration.
This commit is contained in:
14
plugins/chat/app/jobs/scheduled/chat_periodical_updates.rb
Normal file
14
plugins/chat/app/jobs/scheduled/chat_periodical_updates.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class ChatPeriodicalUpdates < ::Jobs::Scheduled
|
||||
every 15.minutes
|
||||
|
||||
def execute(args = nil)
|
||||
# TODO: Add rebaking of old messages (baked_version <
|
||||
# ChatMessage::BAKED_VERSION or baked_version IS NULL)
|
||||
ChatChannel.ensure_consistency!
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
# TODO (martin) Move into ChatChannel.ensure_consistency! so it
|
||||
# is run with ChatPeriodicalUpdates
|
||||
class UpdateUserCountsForChatChannels < ::Jobs::Scheduled
|
||||
every 1.hour
|
||||
|
||||
|
||||
Reference in New Issue
Block a user