Skip to content

Commit

Permalink
Merge pull request #1379 from mozilla/optimize-pre-fxa-query
Browse files Browse the repository at this point in the history
optimize query for sending email to pre-FXA subs
  • Loading branch information
groovecoder authored Nov 19, 2019
2 parents 32678a4 + c02c133 commit 72c43db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions db/migrations/20191118170713_add-email_addresses-email-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";


exports.up = function(knex) {
return knex.schema.table("email_addresses", table => {
table.index("email", "email_addresses_email_idx");
});
};

exports.down = function(knex) {
return knex.schema.table("email_addresses", table => {
table.dropIndex("email", "email_addresses_email_idx");
});
};
3 changes: 2 additions & 1 deletion scripts/send-email-to-pre-fxa-subscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const { LocaleUtils } = require ("../locale-utils");
);

if (!notifiedSubscribers.includes(subscriberEmail)) {
await EmailUtils.sendEmail(
const sendInfo = await EmailUtils.sendEmail(
subscriberEmail,
LocaleUtils.fluentFormat(supportedLocales, "pre-fxa-subject"), // email subject
"default_email", // email template
Expand All @@ -43,6 +43,7 @@ const { LocaleUtils } = require ("../locale-utils");
},
);
notifiedSubscribers.push(subscriberEmail);
console.log(`Sent email to ${subscriberEmail}, info: ${JSON.stringify(sendInfo)}`);
}
}
console.log(`Notified subscribers: ${JSON.stringify(notifiedSubscribers)}`);
Expand Down

0 comments on commit 72c43db

Please sign in to comment.