-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added docs for most bulk-delivery-related scripts
- Loading branch information
Showing
6 changed files
with
83 additions
and
25 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -33,19 +33,31 @@ function getEmailTemplateParameters(route, tickets) { | |
} | ||
|
||
async function main() { | ||
const usageText = 'Usage: $0 --delivery-date YYYY-MM-DD [OPTIONS]' | ||
+ '\n\nSends an email to delivery volunteers registered to deliver on the specified delivery date, with instructions about delivery day, and the tickets assigned to them with information they will need.' | ||
+ '\n\nIf you need to email just one volunteer, use --route to select one route number for that date.' | ||
+ '\n\nWith --dry-run, the email content will be printed to the console.' | ||
+ '\n\nTo include yourself in the Bcc list (to make sure the emails sent properly), pass --bcc.' | ||
+ '\n\nPreconditions:' | ||
+ '\n\n This script reads the Bulk Delivery Routes table for the specified date, and looks up Delivery Volunteers assigned to those routes, and the Intake Tickets attached to those routes, so check those tables for correctness before running this.'; | ||
const { argv } = yargs | ||
.option('deliveryDate', { | ||
coerce: (x) => new Date(x), | ||
demandOption: true, | ||
describe: 'Date of scheduled delivery (yyyy-mm-dd format)', | ||
}) | ||
.option('route', { | ||
coerce: String, | ||
demandOption: false, | ||
describe: 'Email just one delivery volunteer for a specific route ID', | ||
describe: 'Send email for a specific route ID', | ||
type: 'string', | ||
}) | ||
.boolean('dryRun'); | ||
.option('bcc', { | ||
demandOption: false, | ||
describe: 'Add Bcc recipient(s) to all emails (comma separated)', | ||
type: 'string', | ||
}) | ||
.boolean('dryRun') | ||
.usage(usageText); | ||
|
||
const routes = argv.route ? ( | ||
await getRecordsWithFilter(BULK_DELIVERY_ROUTES_TABLE, { deliveryDate: argv.deliveryDate, name: argv.route }) | ||
|
@@ -66,18 +78,21 @@ async function main() { | |
return new Email(markdown, { | ||
to: view.to, | ||
cc: '[email protected]', | ||
bcc: _.map(_.split(argv.bcc || '', ','), (address) => _.trim(address)), | ||
replyTo: '[email protected]', | ||
subject: `[BSS Bulk Ordering] ${view.deliveryDateString} Delivery Prep and Instructions for ${view.firstName}`, | ||
}); | ||
}); | ||
|
||
if (argv.dryRun) { | ||
console.log(emails); | ||
_.forEach(emails, (email) => console.log(email.render())); | ||
} else { | ||
await Promise.all(_.map(emails, (email) => { | ||
return email.send(); | ||
})); | ||
} | ||
|
||
console.log('********************************************************************************\n\nNEXT STEPS!\n\nYou sent the delivery volunteers their coordination emails, they are all set to deliver! Great job!\n\n********************************************************************************'); | ||
} | ||
|
||
main().then( | ||
|
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 |
---|---|---|
|
@@ -9,13 +9,29 @@ const { reconcileOrders, getAllRoutes } = require('../airtable'); | |
const { Email, googleMapsUrl } = require('../messages'); | ||
|
||
async function main() { | ||
const usageText = 'Usage: $0 --delivery-date YYYY-MM-DD [OPTIONS]' | ||
+ '\n\nSends an email to shopping volunteers registered to do custom shopping on the specified delivery date, with instructions about delivery day, and shopping lists for the tickets assigned to them.' | ||
+ '\n\nWith --dry-run, the email content will be printed to the console.' | ||
+ '\n\nTo include yourself in the Bcc list (to make sure the emails sent properly), pass --bcc.' | ||
+ '\n\nPreconditions:' | ||
+ '\n\n This script reads the Bulk Delivery Routes table for the specified date, and looks up Shopping Volunteers assigned to those routes, and the Intake Tickets attached to those routes, so check those tables for correctness before running this.' | ||
+ '\n\n This script also reads the Bulk Order table to compare it with the total groceries requested in tickets scheduled for bulk delivery, to determine what extra items we did not procure, which shoppers need to fulfill, so check to make sure that table has been updated to reflect the actually procured bulk items before running this.' | ||
+ '\n\n You should run this together with generate-packing-slips.js, so that the shopping lists for shopping volunteers accurately match the items in the Other category on the packing slips.' | ||
+ '\n\n You should probably run this in --dry-run mode, and generate the packing slips, and check at least a few tickets to make sure that the shopping lists match the Other category on the packing slips, before sending the packing slips to Brooklyn Packers or the shopping lists to our Shopping Volunteers.' | ||
+ '\n\n Finally, check with the Bulk Delivery Coordinator for this week to find out if there are any special items this week---either bulk items we need Shopping Volunteers to fill in the gaps on, or custom items we can actually provide in a bulk-like way that are not in the Bulk Order table. Check the source code for this script, there is a "CUSTOMIZATION" section you may need to edit in that case.'; | ||
const { argv } = yargs | ||
.option('deliveryDate', { | ||
coerce: (x) => new Date(x), | ||
demandOption: true, | ||
describe: 'Date of scheduled delivery (yyyy-mm-dd format)', | ||
}) | ||
.boolean('dryRun'); | ||
.option('bcc', { | ||
demandOption: false, | ||
describe: 'Add Bcc recipient(s) to all emails (comma separated)', | ||
type: 'string', | ||
}) | ||
.boolean('dryRun') | ||
.usage(usageText); | ||
|
||
// -------------------------------------------------------------------------- | ||
// CUSTOMIZATION | ||
|
@@ -117,6 +133,7 @@ async function main() { | |
return new Email(markdown, { | ||
to: view.to, | ||
cc: '[email protected]', | ||
bcc: _.map(_.split(argv.bcc || '', ','), (address) => _.trim(address)), | ||
replyTo: '[email protected]', | ||
subject: `[BSS Bulk Ordering] ${view.deliveryDateString} Delivery Prep and Instructions for ${view.firstName}`, | ||
}); | ||
|
@@ -125,13 +142,11 @@ async function main() { | |
if (argv.dryRun) { | ||
_.forEach(emails, (email) => console.log(email.render())); | ||
} else { | ||
await Promise.all( | ||
_.map(emails, (email) => { | ||
return email.send(); | ||
}) | ||
); | ||
await Promise.all(_.map(emails, (email) => { | ||
return email.send(); | ||
})); | ||
} | ||
return null; | ||
console.log('********************************************************************************\n\nNEXT STEPS!\n\nYou sent the shopping volunteers their coordination emails, they are all set to go shopping! Great job!\n\n********************************************************************************'); | ||
} | ||
|
||
main() | ||
|
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
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