reclaim existing deprecated feature flag

This commit is contained in:
Tanmay Deep Sharma
2026-02-27 12:15:57 +05:30
parent 62f77d1091
commit 9cd08f4075
4 changed files with 17 additions and 14 deletions
+2 -5
View File
@@ -187,13 +187,10 @@ class ConversationFinder
end
def set_count_for_all_conversations
# Check if filtering by status only (no other filters applied)
filtering_by_status_only = FILTER_PARAMS.none? { |key| params[key] }
# Use cache only for admins (non-admins have inbox permission filters applied)
# Use cache only for admins with no filters other than status
use_cache = current_account.feature_enabled?(:counter_cache_optimization) &&
@is_admin &&
filtering_by_status_only &&
FILTER_PARAMS.none? { |key| params[key] } &&
params[:status] != 'all'
all_count = if use_cache
+4 -8
View File
@@ -17,10 +17,10 @@
display_name: Facebook Channel
enabled: true
help_url: https://chwt.app/hc/fb
- name: channel_twitter
display_name: Twitter Channel
enabled: true
deprecated: true
- name: counter_cache_optimization
display_name: Counter Cache Optimization
enabled: false
chatwoot_internal: true
- name: ip_lookup
display_name: IP Lookup
enabled: false
@@ -243,7 +243,3 @@
display_name: Advanced Assignment
enabled: false
premium: true
- name: counter_cache_optimization
display_name: Counter Cache Optimization
enabled: false
chatwoot_internal: true
@@ -0,0 +1,10 @@
# counter_cache_optimization reclaims the deprecated channel_twitter bit (position 4).
# channel_twitter was enabled: true, so all existing accounts have bit 4 set to 1.
# counter_cache_optimization is enabled: false, so we must clear bit 4 for all accounts.
class DisableCounterCacheOptimizationForExistingAccounts < ActiveRecord::Migration[7.0]
def up
Account.find_in_batches(batch_size: 100) do |accounts|
accounts.each { |account| account.disable_features!(:counter_cache_optimization) }
end
end
end
+1 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2026_02_26_084618) do
ActiveRecord::Schema[7.1].define(version: 2026_02_26_125101) do
# These extensions should be enabled to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"