feat(perf): Cache labels on the conversation model (#8527)
This commit is contained in:
19
db/migrate/20231211010807_add_cached_labels_list.rb
Normal file
19
db/migrate/20231211010807_add_cached_labels_list.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class AddCachedLabelsList < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :conversations, :cached_label_list, :string
|
||||
Conversation.reset_column_information
|
||||
ActsAsTaggableOn::Taggable::Cache.included(Conversation)
|
||||
|
||||
update_exisiting_conversations
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_exisiting_conversations
|
||||
::Account.find_in_batches do |account_batch|
|
||||
account_batch.each do |account|
|
||||
Migration::ConversationCacheLabelJob.perform_later(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_12_01_014644) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_12_11_010807) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
enable_extension "pg_trgm"
|
||||
@@ -453,6 +453,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_12_01_014644) do
|
||||
t.integer "priority"
|
||||
t.bigint "sla_policy_id"
|
||||
t.datetime "waiting_since"
|
||||
t.string "cached_label_list"
|
||||
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
|
||||
t.index ["account_id", "id"], name: "index_conversations_on_id_and_account_id"
|
||||
t.index ["account_id", "inbox_id", "status", "assignee_id"], name: "conv_acid_inbid_stat_asgnid_idx"
|
||||
|
||||
Reference in New Issue
Block a user