Add first_reply_created event in conversation (#4576)

This commit is contained in:
Aswin Dev P.S
2022-05-19 09:46:33 +05:30
committed by GitHub
parent 20565d09c0
commit 8538660bbd
6 changed files with 117 additions and 22 deletions

View File

@@ -0,0 +1,23 @@
class AddFirstReplyActivityAtToConversation < ActiveRecord::Migration[6.1]
def change
add_column :conversations, :first_reply_created_at, :datetime
add_index :conversations, :first_reply_created_at
# rubocop:disable Rails/SkipsModelValidations
::Conversation.update_all(first_reply_created_at: Time.now.utc)
# rubocop:enable Rails/SkipsModelValidations
backfill_first_reply_activity_at_to_conversations
end
private
def backfill_first_reply_activity_at_to_conversations
::Account.find_in_batches do |account_batch|
Rails.logger.info "Migrated till #{account_batch.first.id}\n"
account_batch.each do |account|
Migration::ConversationsFirstReplySchedulerJob.perform_later(account)
end
end
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_05_11_072655) do
ActiveRecord::Schema.define(version: 2022_05_13_145010) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
@@ -385,11 +385,13 @@ ActiveRecord::Schema.define(version: 2022_05_11_072655) do
t.datetime "snoozed_until"
t.jsonb "custom_attributes", default: {}
t.datetime "assignee_last_seen_at"
t.datetime "first_reply_created_at"
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
t.index ["account_id"], name: "index_conversations_on_account_id"
t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id"
t.index ["campaign_id"], name: "index_conversations_on_campaign_id"
t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_id"
t.index ["first_reply_created_at"], name: "index_conversations_on_first_reply_created_at"
t.index ["last_activity_at"], name: "index_conversations_on_last_activity_at"
t.index ["status", "account_id"], name: "index_conversations_on_status_and_account_id"
t.index ["team_id"], name: "index_conversations_on_team_id"