Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike Batch Notify #1749

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

jonathangoulding
Copy link
Collaborator

https://eaflood.atlassian.net/browse/WATER-4904

Get the batch notifications working and dive out the design / structure of the code.

https://eaflood.atlassian.net/browse/WATER-4904

Get the batch notifications working and dive out the design / structure of the code.
@jonathangoulding jonathangoulding self-assigned this Feb 26, 2025
@jonathangoulding jonathangoulding added the do not merge Used for spikes and experiments label Feb 26, 2025
async function _sendLetter(recipient) {
const data = _formatLetter(recipient)

return NotifyLetterService.go(data.templateId, data.options).then((res) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems necessary to allow the Notify functions to be a simple notify response and not worry about returning the personalisation and contact hash to the caller.

We need the contact hash if there is an error to retry the notify calls - will need to this in the catch. ?

* @param returnsPeriod
* @param referenceCode
*/
function go(recipient, returnsPeriod, referenceCode) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presenters make sense to format the data for the notify calls.

The question would be should we do it before each request is made. Or format all the recipients into notifications.

I am leaning to changing all in the recipients in the array into a something like notifications. As we have a clear delineation between a recipient and a notification.

As we are using the existing DB table with a personalisation column this make sense.

}

async function _sendEmail(recipient, returnsPeriod, referenceCode) {
const formatedData = NotifyEmailPresenter.go(recipient, returnsPeriod, referenceCode)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this to the array prior to this should allow us to handle the errors / success simpler in the batch.

If we can remove the need to use the contact hash then i think this is better.

We get all the results resolved promises and we can handle the errors and resend the 'payload'

  const failed = notifications.filter((response) => response.status !== 'fulfilled')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Used for spikes and experiments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant