feat: add conversation status counter cache with per-account backfill on feature enable

This commit is contained in:
Tanmay Deep Sharma
2026-02-24 16:24:10 +05:30
parent d0525660ab
commit d4992ad4c6
4 changed files with 41 additions and 25 deletions
+8
View File
@@ -144,6 +144,7 @@ class Account < ApplicationRecord
before_validation :validate_limit_keys
after_create_commit :notify_creation
after_destroy :remove_account_sequences
after_save :backfill_conversation_counters_if_needed
def agents
users.where(account_users: { role: :agent })
@@ -208,6 +209,13 @@ class Account < ApplicationRecord
"execute format('create sequence IF NOT EXISTS camp_dpid_seq_%s', NEW.id);"
end
def backfill_conversation_counters_if_needed
return unless saved_change_to_feature_flags?
return unless feature_counter_cache_optimization?
Internal::BackfillConversationCountersJob.perform_later(self)
end
def validate_limit_keys
# method overridden in enterprise module
end