mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 07:30:04 +08:00
DEV: Apply syntax_tree formatting to plugins/*
This commit is contained in:
@ -9,7 +9,10 @@ class Chat::Api::CategoryChatablesController < ApplicationController
|
||||
Group
|
||||
.joins(:category_groups)
|
||||
.where(category_groups: { category_id: category.id })
|
||||
.where("category_groups.permission_type IN (?)", [CategoryGroup.permission_types[:full], CategoryGroup.permission_types[:create_post]])
|
||||
.where(
|
||||
"category_groups.permission_type IN (?)",
|
||||
[CategoryGroup.permission_types[:full], CategoryGroup.permission_types[:create_post]],
|
||||
)
|
||||
.joins("LEFT OUTER JOIN group_users ON groups.id = group_users.group_id")
|
||||
.group("groups.id", "groups.name")
|
||||
.pluck("groups.name", "COUNT(group_users.user_id)")
|
||||
|
@ -9,16 +9,17 @@ class Chat::Api::HintsController < ApplicationController
|
||||
|
||||
raise Discourse::InvalidParameters.new(:mentions) if group_names.blank?
|
||||
|
||||
visible_groups = Group
|
||||
.where("LOWER(name) IN (?)", group_names)
|
||||
.visible_groups(current_user)
|
||||
.pluck(:name)
|
||||
visible_groups =
|
||||
Group.where("LOWER(name) IN (?)", group_names).visible_groups(current_user).pluck(:name)
|
||||
|
||||
mentionable_groups = filter_mentionable_groups(visible_groups)
|
||||
|
||||
result = {
|
||||
unreachable: visible_groups - mentionable_groups.map(&:name),
|
||||
over_members_limit: mentionable_groups.select { |g| g.user_count > SiteSetting.max_users_notified_per_group_mention }.map(&:name),
|
||||
over_members_limit:
|
||||
mentionable_groups
|
||||
.select { |g| g.user_count > SiteSetting.max_users_notified_per_group_mention }
|
||||
.map(&:name),
|
||||
}
|
||||
|
||||
result[:invalid] = (group_names - result[:unreachable]) - result[:over_members_limit]
|
||||
|
@ -5,8 +5,9 @@ module Jobs
|
||||
def execute(args)
|
||||
return if args[:user_id].nil?
|
||||
|
||||
ChatMessageDestroyer.new
|
||||
.destroy_in_batches(ChatMessage.with_deleted.where(user_id: args[:user_id]))
|
||||
ChatMessageDestroyer.new.destroy_in_batches(
|
||||
ChatMessage.with_deleted.where(user_id: args[:user_id]),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -15,10 +15,9 @@ module Jobs
|
||||
return unless valid_day_value?(:chat_channel_retention_days)
|
||||
|
||||
ChatMessageDestroyer.new.destroy_in_batches(
|
||||
ChatMessage
|
||||
.in_public_channel
|
||||
.with_deleted
|
||||
.created_before(SiteSetting.chat_channel_retention_days.days.ago)
|
||||
ChatMessage.in_public_channel.with_deleted.created_before(
|
||||
SiteSetting.chat_channel_retention_days.days.ago,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
@ -26,10 +25,9 @@ module Jobs
|
||||
return unless valid_day_value?(:chat_dm_retention_days)
|
||||
|
||||
ChatMessageDestroyer.new.destroy_in_batches(
|
||||
ChatMessage
|
||||
.in_dm_channel
|
||||
.with_deleted
|
||||
.created_before(SiteSetting.chat_dm_retention_days.days.ago)
|
||||
ChatMessage.in_dm_channel.with_deleted.created_before(
|
||||
SiteSetting.chat_dm_retention_days.days.ago,
|
||||
),
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,6 @@ class ChatChannel < ActiveRecord::Base
|
||||
|
||||
# TODO (martin) Move UpdateUserCountsForChatChannels into here
|
||||
def self.update_counts
|
||||
|
||||
# NOTE: ChatChannel#messages_count 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
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
class ChatMessageDestroyer
|
||||
def destroy_in_batches(chat_messages_query, batch_size: 200)
|
||||
chat_messages_query.in_batches(of: batch_size).each do |relation|
|
||||
destroyed_ids = relation.destroy_all.pluck(:id)
|
||||
reset_last_read(destroyed_ids)
|
||||
delete_flags(destroyed_ids)
|
||||
end
|
||||
chat_messages_query
|
||||
.in_batches(of: batch_size)
|
||||
.each do |relation|
|
||||
destroyed_ids = relation.destroy_all.pluck(:id)
|
||||
reset_last_read(destroyed_ids)
|
||||
delete_flags(destroyed_ids)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
Reference in New Issue
Block a user