tasks: populate Instructeur.bypass_email_login_token again

The task was run once in April 2021, but the new features enabled since
have not been synchronized.
This commit is contained in:
Pierre de La Morinerie 2021-11-25 14:54:37 +01:00
parent 28dfc6a1ba
commit 103502931a

View file

@ -0,0 +1,18 @@
namespace :after_party do
desc 'Deployment task: populate_bypass_email_login'
task populate_bypass_email_login: :environment do
user_ids = Flipper::Adapters::ActiveRecord::Gate
.where(feature_key: 'instructeur_bypass_email_login_token')
.pluck(:value)
.filter { |s| s.start_with?('User:') }
.map { |s| s.gsub('User:', '') }
.map(&:to_i)
Instructeur
.where(user: { id: user_ids })
.update_all(bypass_email_login_token: true)
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end