Skip to content

Commit

Permalink
feat: Enable 2nd part log mentoring sessions reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
helloanil committed Sep 2, 2024
1 parent 50f2d3b commit 100f570
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
44 changes: 25 additions & 19 deletions apps/nestjs-api/src/reminder-emails/reminder-emails.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ export class ReminderEmailsController {
{ mentorshipMatchAgeInDays: 14 }
)

// TODO: Uncomment and merge this two weeks after the first reminder is sent
// const mentorshipMatchesWithMentorAndMenteeDetails_4weeks =
// await this.reminderEmailsService.getMentorsAndMenteesWithoutMentoringSessionsLogged(
// { mentorshipMatchAgeInDays: 28 }
// )
const mentorshipMatchesWithMentorAndMenteeDetails_4weeks =
await this.reminderEmailsService.getMentorsAndMenteesWithoutMentoringSessionsLogged(
{ mentorshipMatchAgeInDays: 28 }
)

if (
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).length > 0
Expand All @@ -200,19 +199,26 @@ export class ReminderEmailsController {
)
}

// TODO: Uncomment and merge this two weeks after the first reminder is sent
// if (
// Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length > 0
// ) {
// // send reminder emails
// Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).forEach(
// async (key) => {
// await this.reminderEmailsService.sendLogMentoringSessionsReminder(
// mentorshipMatchesWithMentorAndMenteeDetails_4weeks[key],
// 28
// )
// }
// )
// }
if (
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length > 0
) {
// send reminder emails
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).forEach(
async (key) => {
await this.reminderEmailsService.sendLogMentoringSessionsReminder(
mentorshipMatchesWithMentorAndMenteeDetails_4weeks[key],
28
)
}
)
}

return {
message: `Mentoring Session Loggging Reminder emails sent: 1st: ${
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_2weeks).length
}, 2nd: ${
Object.keys(mentorshipMatchesWithMentorAndMenteeDetails_4weeks).length
}`,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export class ReminderEmailsService {
const mentorshipMatchesWithSessionsCount = {} as Record<
string,
{
mentorshipMatchId: string,
menteeId: string
mentorId: string
mentoringSessionsCount: number
Expand All @@ -252,6 +253,7 @@ export class ReminderEmailsService {

// Step 2.2: Fill the object with the mentorship match id as key and the mentee id, mentor id and the count of mentoring sessions
mentorshipMatchesWithSessionsCount[match.props.id] = {
mentorshipMatchId: match.props.id,
menteeId: match.props.menteeId,
mentorId: match.props.mentorId,
mentoringSessionsCount: mentoringSessions.length,
Expand Down Expand Up @@ -304,6 +306,7 @@ export class ReminderEmailsService {
)

result[key] = {
mentorshipMatchId: value.mentorshipMatchId,
menteeFirstName: mentee?.props.firstName,
menteeEmail: mentee?.props.email,
mentorFirstName: mentor?.props.firstName,
Expand Down Expand Up @@ -591,6 +594,7 @@ export class ReminderEmailsService {

async sendLogMentoringSessionsReminder(
{
mentorshipMatchId,
menteeFirstName,
menteeEmail,
mentorFirstName,
Expand Down Expand Up @@ -646,6 +650,7 @@ export class ReminderEmailsService {
)
.replace(/{{{Recipient.FirstName}}}/g, mentorFirstName)
.replace(/\${matchMadeActiveOn}/g, matchMadeActiveOn)
.replace(/\${logMentoringSessionUrl}/g, `https://connect.redi-school.org/app/mentorships/${mentorshipMatchId}`)

const menteeParams = {
Destination: {
Expand Down

0 comments on commit 100f570

Please sign in to comment.