diff --git a/packages/server/src/scripts/digest/cron.js b/packages/server/src/scripts/digest/cron.js new file mode 100644 index 0000000000..8b7c8e2603 --- /dev/null +++ b/packages/server/src/scripts/digest/cron.js @@ -0,0 +1,19 @@ +async function run() { + console.log('grants-digest-cron run() is called'); + + /* + The cron is responsible for: + 1. Identifying all unique criteria from grants_saved_searches + 2. Constructing a JSON object with the following for each criteria: + { + criteria: , + user_ids: [, ...], + email_date: , + } + 3. Publish each object created above as a new message in an SQS queue. + */ +} + +module.exports = { + run, +}; diff --git a/packages/server/src/scripts/digest/getGrants.js b/packages/server/src/scripts/digest/getGrants.js new file mode 100644 index 0000000000..9c22e5ec79 --- /dev/null +++ b/packages/server/src/scripts/digest/getGrants.js @@ -0,0 +1,25 @@ +function main() { + console.log('getGrants.js.main() is called'); + /* + The getGrants.js script is responsible for: + 1. Receiving messages from an SQS queue + 2. Parse the message body into an object with the following shape: + { + criteria: , + user_ids: [, ...], + email_date: , + } + 3. For each object, query the grants table for grants that match the criteria + 4. For each user in user_ids, create a JSON object with the following shape: + { + user_id: , + grant_ids: [, ...], + email_date: , + } + 5. Publish each object created above as a new message in an SQS queue. + */ +} + +if (require.main === module) { + main().then(() => process.exit()); +} diff --git a/packages/server/src/scripts/digest/sendEmail.js b/packages/server/src/scripts/digest/sendEmail.js new file mode 100644 index 0000000000..9358da0f7c --- /dev/null +++ b/packages/server/src/scripts/digest/sendEmail.js @@ -0,0 +1,7 @@ +function main() { + console.log('sendEmail.main() is called'); +} + +if (require.main === module) { + main().then(() => process.exit()); +}