Scheduling email sending with Pg-boss
Project Overview
I have developed a feature that allows sending a list of tasks via email to the logged-in user using Mailgun. I now want to enhance this functionality by implementing a subscription service for users to receive a digest of new tasks based on a search profile.
Key Requirements
- **Subscription Feature**:
- Users can subscribe to a search profile.
- Each search profile will have criteria such as
minPriceandmaxPriceto filter tasks.
- **Email Digest**:
- A digest of new tasks meeting the search profile criteria will be sent via email.
- Users can choose the frequency of the email: daily or weekly.
- **Scheduling with pg-boss**:
- Use
pg-bossfor scheduling the email dispatch. - The scheduling should support both daily (cron string:
0 0 * * *) and weekly (cron string:0 0 * * 5) options based on user preference.
- Use
I need assistance with the following:
- **Implementation of the Subscription Logic**:
- How to allow users to create and manage their search profiles.
- Storing user preferences for email frequency.
- **Integration with pg-boss**:
- Setting up pg-boss to handle the scheduling based on user preferences.
- Ensuring the correct cron string is used for each user’s chosen frequency.
- **Email Sending**:
- Filtering tasks based on the search profile criteria (
minPriceandmaxPrice). - Formatting the tasks into a digest and sending the email using Mailgun.
- Filtering tasks based on the search profile criteria (
Kapa.ai Could you provide a detailed implementation plan or example code snippets to achieve this?