Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt Out Petition Emails Under 16 #22671

Merged
merged 2 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions bin/oneoff/wipe_data/opt_out_petition_emails_under_16
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby

# This script sets EmailPreference.opt_in to false for any person who submitted a Pegasus Petition form and was less
# than 16 years old when they submitted the form because GDPR requires someone to be at least 16 to consent to opt in.
# Before mid-May 2018, the Petition form anonymized email addresses submitted by people younger than 13. Starting in
# mid-May 2018 the Petition form anonymizes email addresses submitted by anyone under 16. This script does not
# anonymize or delete email addresses submitted by Petitioners who were between the ages of 13 and 16 because
# our Contact Rollups process does not currently have any functionality to delete emails from Pardot that were deleted
# in our database, but it does comply with GDPR by opting out those email addresses.

require File.expand_path('../../../../pegasus/src/env', __FILE__)
require src_dir 'database'
load pegasus_dir('helpers.rb')
require 'cdo/only_one'

def main
CDO.log.info "Starting to Opt Out Petition Emails Under 16"
# This query loads about 200_000 (200K) rows into memory.
DB[:forms].
select(:email).
where(kind: 'Petition').
# Skip Petitions from people under 13, because they were already anonymized.
where(Sequel.~(email: 'anonymous@code.org')).
where(Sequel.lit("JSON_EXTRACT(data, '$.age_i') < 16")).
each do |petition|
EmailPreferenceHelper.upsert!(
email: petition[:email],
opt_in: false,
source: EmailPreferenceHelper::AUTOMATED_OPT_OUT_UNDER_16,
ip_address: '127.0.0.1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the IP address recorded when the form was saved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're the ones making the decision to opt them out, so it seems more accurate to log "our" IP address?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point. Should we make that a constant indicating that case, and maybe even put it into EmailPreference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Done!

form_kind: '0'
)
end
CDO.log.info "Finished Opt Out of Petition Emails Under 16"
end

main if only_one_running?(__FILE__)
3 changes: 3 additions & 0 deletions lib/cdo/email_preference_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ module EmailPreferenceConstants
FORM_HOC_SIGN_UP = 'FORM_HOC_SIGN_UP'.freeze,
FORM_CLASS_SUBMIT = 'FORM_CLASS_SUBMIT'.freeze,
FORM_PETITION = 'FORM_PETITION'.freeze,
# A one-time automated script sets all Petition submissions younger than 16 and older than 13 to opted out to comply
# with GDPR.
AUTOMATED_OPT_OUT_UNDER_16 = 'AUTOMATED_OPT_OUT_UNDER_16'.freeze
].freeze
end