feat(perf): Cache labels on the conversation model (#8527)

This commit is contained in:
Pranav Raj S
2023-12-11 18:27:55 -08:00
committed by GitHub
parent 79412ba2c6
commit 890515edfd
9 changed files with 48 additions and 53 deletions

View File

@@ -0,0 +1,16 @@
class Migration::ConversationCacheLabelJob < 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(account)
account.conversations.find_in_batches do |conversation_batch|
conversation_batch.each do |conversation|
conversation.label_list
conversation.save!
end
end
end
end