-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
640f611
commit 40921d6
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
lib/tasks/data_migration/backfill_subscribers_to_announcements_mailing_list.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# typed: strict | ||
# frozen_string_literal: true | ||
|
||
extend Rake::DSL # rubocop:disable Style/MixinUsage | ||
|
||
namespace :data_migration do | ||
desc "Backfill the first_approved_at date for already approved reviews" | ||
task backfill_subscribers_to_announcements_mailing_list: :environment do | ||
Rails.logger = Logger.new($stdout) | ||
ActiveRecord::Base.logger = Rails.logger | ||
|
||
# Change to :debug for ActiveRecord SQL logs. | ||
Rails.logger.level = :info | ||
|
||
ActiveRecord::Base.transaction do | ||
User.all.find_each do |user| | ||
user.subscribe("announcements") unless user.subscribed?("announcements") | ||
user.save | ||
end | ||
end | ||
end | ||
end |