From 4756141156e3c4525fff0a80568b788aadffc378 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 27 Dec 2020 04:45:46 -0600 Subject: [PATCH] emails: add script to delete invalid emails. We used to not validate user email addresses, which means we have a lot of users with invalid emails. This script deletes all emails that are missing both an `@` and a `.` This amounts to about 3000 invalid emails. There are an additional ~1000 emails that are missing just the `@` sign. Many of these are simple typos, for example skipping the `@` or typing a 2 instead. Some of these may be manually fixable. This fixes an issue where upgrading to Gold could fail if you had an invalid email address, because we prefilled the buyer's email address on the Stripe checkout page and an invalid email would cause Stripe to throw an error. --- script/fixes/067_delete_invalid_email_addresses.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 script/fixes/067_delete_invalid_email_addresses.rb diff --git a/script/fixes/067_delete_invalid_email_addresses.rb b/script/fixes/067_delete_invalid_email_addresses.rb new file mode 100755 index 000000000..00b96902a --- /dev/null +++ b/script/fixes/067_delete_invalid_email_addresses.rb @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +require_relative "../../config/environment" + +EmailAddress.transaction do + EmailAddress.where("address !~ ? AND address !~ ?", "@", "\\.").count +end