fix: migration script to run on all reporting events (#6590)

* fix: migration script to run on all reporting events

* fix: don't update user_id if it is already present

* refactor: create a new migration

* feat: update schema

* feat: ignore events with bot handoff

* feat: prefetch conversations with handoff events

* Revert "feat: update schema"

This reverts commit 25ed2856e62655f5f1db14fd0cffad3a69d0b1fb.

* feat: update schema

* refactor: separate method get_conversations_with_bot_handoffs

* refactor: cognitive complexity

* refactor: early return if last_bot_reply is blank

* feat: add async_database_migration queue

* feat: update queue priority
This commit is contained in:
Shivam Mishra
2023-03-02 19:03:31 +05:30
committed by GitHub
parent b185059681
commit a6405ea339
5 changed files with 40 additions and 26 deletions

View File

@@ -1,10 +1,5 @@
class UpdateReportingEventsWithIncorrectFirstResponses < ActiveRecord::Migration[6.1]
def change
::Account.find_in_batches do |account_batch|
Rails.logger.info "Updated reporting events till #{account_batch.first.id}\n"
account_batch.each do |account|
Migration::UpdateFirstResponseTimeInReportingEventsJob.perform_later(account)
end
end
Rails.logger.info "Skipping this migration, it's replaced by a new one"
end
end

View File

@@ -0,0 +1,10 @@
class UpdateReportingEventsFirstResponseTime < ActiveRecord::Migration[6.1]
def change
::Account.find_in_batches do |account_batch|
Rails.logger.info "Updated reporting events till #{account_batch.first.id}\n"
account_batch.each do |account|
Migration::UpdateFirstResponseTimeInReportingEventsJob.perform_later(account)
end
end
end
end