fix(flipper): really setup missing (not enabled) feature

This commit is contained in:
Colin Darie 2024-07-31 16:05:45 +02:00
parent a316600e7a
commit 99fd12beb8
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4

View file

@ -6,7 +6,7 @@ require 'flipper/adapters/active_record'
require 'flipper/adapters/active_support_cache_store'
def setup_features(features)
existing = Flipper.preload(features).map { _1.name.to_sym }
existing = Flipper.preload_all.map { _1.name.to_sym }
missing = features - existing
missing.each do |feature|
@ -41,12 +41,6 @@ rescue ActiveRecord::ConnectionNotEstablished, ActiveRecord::NoDatabaseError, PG
false
end
ActiveSupport.on_load(:active_record) do
if database_exists? && ActiveRecord::Base.connection.data_source_exists?('flipper_features')
setup_features(features)
end
end
Flipper.configure do |config|
config.adapter do
Flipper::Adapters::ActiveSupportCacheStore.new(
@ -57,6 +51,12 @@ Flipper.configure do |config|
end
end
ActiveSupport.on_load(:active_record) do
if database_exists? && ActiveRecord::Base.connection.data_source_exists?('flipper_features')
setup_features(features)
end
end
Rails.application.configure do
config.flipper.actor_limit = 500 # default is 100 but hide_instructeur_email feature has ~478
# don't preload features for /assets/* but do for everything else