Remove Unused ChatChannel Indexing (#5907) [deploy]

* remove unused algolia code from chat channel

* remove new chat_channel index code and unused methods
This commit is contained in:
Molly Struve 2020-02-07 12:39:59 -05:00 committed by GitHub
parent 69b04d38aa
commit e159217dce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 29 deletions

View file

@ -19,7 +19,6 @@ class ChatChannelMembershipsController < ApplicationController
chat_channel_id: @chat_channel.id,
status: "pending",
)
@chat_channel.index!
end
def update
@ -31,7 +30,6 @@ class ChatChannelMembershipsController < ApplicationController
else
@chat_channel_membership.update(status: "rejected")
end
@chat_channel_membership.chat_channel.index!
@chat_channels_memberships = current_user.
chat_channel_memberships.includes(:chat_channel).
where(status: "pending").
@ -45,7 +43,6 @@ class ChatChannelMembershipsController < ApplicationController
authorize @chat_channel_membership
@chat_channel_membership.update(status: "left_channel")
@chat_channel_membership.remove_from_index!
@chat_channel_membership.chat_channel.index!
@chat_channels_memberships = []
render json: { result: "left channel" }, status: :created
end

View file

@ -38,7 +38,6 @@ class ChatChannelsController < ApplicationController
membership = @chat_channel.chat_channel_memberships.where(user_id: current_user.id).first
membership.update(last_opened_at: 1.second.from_now, has_unopened_messages: false)
send_open_notification
@chat_channel.index!
membership.index!
render json: { status: "success", channel: params[:id] }, status: :ok
end

View file

@ -1,5 +1,4 @@
class ChatChannel < ApplicationRecord
include AlgoliaSearch
attr_accessor :current_user, :usernames_string
has_many :messages, dependent: :destroy
@ -19,18 +18,6 @@ class ChatChannel < ApplicationRecord
validates :status, presence: true, inclusion: { in: %w[active inactive blocked] }
validates :slug, uniqueness: true, presence: true
algoliasearch index_name: "SecuredChatChannel_#{Rails.env}" do
attribute :id, :viewable_by, :slug, :channel_type,
:channel_name, :last_message_at, :status,
:messages_count, :channel_human_names, :channel_mod_ids, :pending_users_select_fields,
:description
searchableAttributes %i[channel_name channel_slug channel_human_names]
attributesForFaceting ["filterOnly(viewable_by)", "filterOnly(status)", "filterOnly(channel_type)"]
ranking ["desc(last_message_at)"]
end
before_destroy :remove_from_index!, prepend: true
def open?
channel_type == "open"
end
@ -90,7 +77,6 @@ class ChatChannel < ApplicationRecord
status: "active",
)
channel.add_users(users)
channel.index!
channel.chat_channel_memberships.map(&:index!)
end
channel
@ -131,14 +117,6 @@ class ChatChannel < ApplicationRecord
end
end
def viewable_by
active_memberships.pluck(:user_id)
end
def messages_count
messages.size
end
def channel_human_names
active_memberships.
order("last_opened_at DESC").limit(5).includes(:user).map do |membership|
@ -147,7 +125,6 @@ class ChatChannel < ApplicationRecord
end
def channel_users
# Purely for algolia indexing
obj = {}
relation = active_memberships.includes(:user).select(:id, :user_id, :last_opened_at)

View file

@ -27,7 +27,6 @@ class Message < ApplicationRecord
def update_chat_channel_last_message_at
chat_channel.touch(:last_message_at)
chat_channel.index!
chat_channel.chat_channel_memberships.reindex!
end

View file

@ -4,7 +4,6 @@ module Users
# We only destroy direct message channels, not open and invite-only ones
direct_channels = user.chat_channels.where(channel_type: "direct")
direct_channels.each do |direct_channel|
direct_channel.remove_from_index!
cleanup_memberships(direct_channel.chat_channel_memberships)
direct_channel.destroy!
end