Added missing weight emails
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Queue } from 'bullmq';
|
||||
import { redisConnection } from './redisConnection.js';
|
||||
|
||||
export const weightReminderQueueName = 'weight-reminders';
|
||||
export const weightReminderQueue = new Queue(weightReminderQueueName, {
|
||||
connection: redisConnection,
|
||||
defaultJobOptions: {
|
||||
attempts: 3,
|
||||
backoff: { type: 'exponential', delay: 60_000 },
|
||||
removeOnComplete: 100,
|
||||
removeOnFail: 1000,
|
||||
},
|
||||
});
|
||||
|
||||
export const startWeightReminderScheduler = async () => {
|
||||
if (process.env.WEIGHT_REMINDERS_ENABLED === 'false') {
|
||||
await weightReminderQueue.removeJobScheduler('weight-reminders');
|
||||
return;
|
||||
}
|
||||
await weightReminderQueue.setGlobalConcurrency(1);
|
||||
await weightReminderQueue.upsertJobScheduler(
|
||||
'weight-reminders',
|
||||
{ every: 5 * 60_000 },
|
||||
{ name: 'check-overdue-weights', data: {} },
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user