A support request that came to Chatwoot Cloud revealed that the job was timed prematurely. The default timeout for Sidekiq queues was set as 25 minutes in sidekiq.yml file. The cache was not created properly for the accounts with more than 100k conversations. This change removes the cache logic in the previous migration and creates a new migration with a new job which processes conversations in batch.
15 lines
578 B
Ruby
15 lines
578 B
Ruby
class Migration::ConversationBatchCacheLabelJob < ApplicationJob
|
|
queue_as :async_database_migration
|
|
|
|
# To cache the label, we simply access it from the object and save it. Anytime the object is
|
|
# saved in the future, ActsAsTaggable will automatically recompute it. This process is done
|
|
# initially when the user has not performed any action.
|
|
# Reference: https://github.com/mbleigh/acts-as-taggable-on/wiki/Caching
|
|
def perform(conversation_batch)
|
|
conversation_batch.each do |conversation|
|
|
conversation.label_list
|
|
conversation.save!
|
|
end
|
|
end
|
|
end
|