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

Implement Automatic remainder sending email service #177

Closed

Conversation

mayura-andrew
Copy link
Member

Purpose

The purpose of this PR is to fix #176

This issue involves enhancing the EmailReminderService to ensure that email reminders are scheduled and processed correctly, with proper handling of retries and failures.

Goals

  1. Implement a robust EmailReminderService that schedules and processes email reminders.
  2. Ensure that reminders are retried with exponential backoff in case of failures.
  3. Handle maximum retries by logging and saving failed reminders.
  4. Improve the overall reliability and maintainability of the reminder service.

Approach

  1. Added a constructor to the EmailReminders entity to initialize properties correctly.
  2. Implemented the processReminders method to handle pending reminders, including retries and exponential backoff.
  3. Added logging to track the scheduling and processing of reminders.
  4. Ensured proper transaction management in the scheduleReminders method.

Screenshots

Checklist

  • This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Related PRs

Test environment

Learning

mayura-andrew and others added 30 commits July 14, 2024 20:28
Instead of directly passing individual fields to the updateProfile function, refactor the logic to use a single updateData object. This object contains the updated fields for the profile, such as primary_email, first_name, last_name, and image_url. This change improves code readability and maintainability.

Related to sef-global#165
- Moved monthly checking service functions to a dedicated service file (monthlyChecking.service.ts).
- Moved monthly checking controller functions to a dedicated controller file (monthlyChecking.controller.ts).
- Updated import paths and references to reflect the new file structure.
- Improved code organization and maintainability by separating concerns.
@mayura-andrew mayura-andrew changed the title Remainder email Implement Automatic remainder sending email service Oct 27, 2024
@mayura-andrew mayura-andrew marked this pull request as draft October 27, 2024 14:12
@@ -10,7 +10,6 @@ import {
capitalizeFirstLetter
} from '../utils'
import { sendEmail } from './admin/email.service'

Copy link
Member

Choose a reason for hiding this comment

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

Add the space here

}

private async getPendingAttempts(): Promise<ReminderAttempt[]> {
console.log('Fetching pending attempts')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log('Fetching pending attempts')

this.configRepository = dataSource.getRepository(MenteeReminderConfig)
this.menteeRepository = dataSource.getRepository(Mentee)
this.attemptRepository = dataSource.getRepository(ReminderAttempt)
console.log('EmailReminderService initialized')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log('EmailReminderService initialized')

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove these console.logs

res: Response
): Promise<void> => {
try {
res.status(200).json({ message: 'Reminder enabled' })
Copy link
Member

Choose a reason for hiding this comment

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

What is the purpose of this?

Copy link
Member Author

@mayura-andrew mayura-andrew Oct 31, 2024

Choose a reason for hiding this comment

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

this is a API endpoint but not implemented yet. I'll implement this soon as possible :)

… for processing and scheduling reminders, and enhance reminder service logic
package.json Outdated
"dotenv": "^16.3.1",
"ejs": "^3.1.10",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"node-cron": "^3.0.3",
Copy link
Member

Choose a reason for hiding this comment

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

Remove this if not required

Suggested change
"node-cron": "^3.0.3",

@@ -56,6 +58,7 @@
"@types/jsonwebtoken": "^9.0.2",
"@types/multer": "^1.4.11",
"@types/node": "^20.1.4",
"@types/node-cron": "^3.0.11",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"@types/node-cron": "^3.0.11",

… status enums, and implement dynamic next reminder date calculation
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.

Implement monthly-checking reminder service
2 participants