From b3e95c395534057ef9983910ef765f4d281e9417 Mon Sep 17 00:00:00 2001 From: Luke Crouch Date: Thu, 19 Sep 2019 09:36:40 -0500 Subject: [PATCH] for #976: tweaks to log and exit lower-casing script --- scripts/lowercase-all-records.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/lowercase-all-records.js b/scripts/lowercase-all-records.js index e5e729e99e6..025cc939004 100644 --- a/scripts/lowercase-all-records.js +++ b/scripts/lowercase-all-records.js @@ -20,6 +20,8 @@ async function subscribeLowercaseHashToHIBP(emailAddress) { (async () => { const subRecordsWithUpperChars = await knex("subscribers") .whereRaw("primary_email != lower(primary_email)"); + const subsWithUpperCount = subRecordsWithUpperChars.length; + console.log(`found ${subsWithUpperCount} subscribers records with primary_email != lower(primary_email). fixing ...`); for (const subRecord of subRecordsWithUpperChars) { const lowerCasedSha1 = await subscribeLowercaseHashToHIBP(subRecord.primary_email); await knex("subscribers") @@ -27,10 +29,13 @@ async function subscribeLowercaseHashToHIBP(emailAddress) { primary_sha1: lowerCasedSha1, }) .where("id", subRecord.id); + console.log(`fixed subscribers record ID: ${subRecord.id}`); } const emailRecordsWithUpperChars = await knex("email_addresses") .whereRaw("email != lower(email)"); + const emailsWithUpperCount = emailRecordsWithUpperChars.length; + console.log(`found ${emailsWithUpperCount} email_addresses records with email != lower(email)`); for (const emailRecord of emailRecordsWithUpperChars) { const lowerCasedSha1 = await subscribeLowercaseHashToHIBP(emailRecord.email); await knex("email_addresses") @@ -38,5 +43,8 @@ async function subscribeLowercaseHashToHIBP(emailAddress) { sha1: lowerCasedSha1, }) .where("id", emailRecord.id); + console.log(`fixed email_addresses record ID: ${emailRecord.id}`); } + console.log("done."); + process.exit(); })();