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

[CHORE] Saving sent mail list in db #485

Merged
merged 15 commits into from
Jan 27, 2025
Merged

Conversation

chelsea-EYDS
Copy link
Collaborator

@chelsea-EYDS chelsea-EYDS commented Jan 26, 2025

CHORE

deployed and tested on dev

Objective:

  • created two new entities: one for saving a batch record, and one for the individuals messages.
  • If an email address is filtered it will be logged as not sent in order to manually review/address each case
  • After sending the emails we can run the check mail job to ensure the status is complete for all sent mail
  • Job also checks for any missing entries in the mail logs who should have been emailed based in the recommitment status

@chelsea-EYDS chelsea-EYDS changed the base branch from seed-recommitment to main January 26, 2025 02:03
@chelsea-EYDS chelsea-EYDS force-pushed the CHORE-record-mail-sent branch from 29cf36b to 4181c84 Compare January 26, 2025 02:04
this.logger.log(res?.data);

const batch =
res.data.txId &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems overkill to do this given the check in line 271

`Emails sent for ${templateType}: ${res.data.messages.length}`,
);

if (!res.data.txId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to do !res?.data?.txId?

});
});

mails.length > 0 && (await this.mailRepository.save(mails));
Copy link
Collaborator

Choose a reason for hiding this comment

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

By and large, I'd prefer using if statements to && just because they're more self explanatory.

Also, in this case, mails could technically be empty from line 289 if, for example, batch is undefined for any reason, so this could crash when mails.length is searching for length of undefined

(itm) => !existingEmails?.includes(itm.to[0]),
);

if (existingEmails?.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

filteredEmails?.length

}),
);

if (batch.txId && res.data?.messages.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

res.data?.messages?.length
?

@chelsea-EYDS chelsea-EYDS merged commit df9457e into main Jan 27, 2025
10 checks passed
@chelsea-EYDS chelsea-EYDS deleted the CHORE-record-mail-sent branch January 27, 2025 02:15
@chelsea-EYDS chelsea-EYDS restored the CHORE-record-mail-sent branch January 27, 2025 22:38
@chelsea-EYDS chelsea-EYDS deleted the CHORE-record-mail-sent branch January 27, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants