misc: updated processes to run after db migration

This commit is contained in:
Sheen Capadngan
2025-10-28 23:08:39 +08:00
parent 1cff5cd7d7
commit 9d61b06eec
6 changed files with 675 additions and 647 deletions
@@ -10,6 +10,7 @@ type TNotificationQueueServiceFactoryDep = {
export type TNotificationQueueServiceFactory = {
pushUserNotifications: (data: TCreateUserNotificationDTO[]) => Promise<void>;
init: () => Promise<void>;
};
export const notificationQueueServiceFactory = async ({
@@ -20,20 +21,23 @@ export const notificationQueueServiceFactory = async ({
await queueService.queuePg(QueueJobs.UserNotification, { notifications: data });
};
await queueService.startPg(
QueueJobs.UserNotification,
async ([job]) => {
const { notifications } = job.data as { notifications: TCreateUserNotificationDTO[] };
await userNotificationDAL.batchInsert(notifications);
},
{
batchSize: 1,
workerCount: 2,
pollingIntervalSeconds: 1
}
);
const init = async () => {
await queueService.startPg(
QueueJobs.UserNotification,
async ([job]) => {
const { notifications } = job.data as { notifications: TCreateUserNotificationDTO[] };
await userNotificationDAL.batchInsert(notifications);
},
{
batchSize: 1,
workerCount: 2,
pollingIntervalSeconds: 1
}
);
};
return {
pushUserNotifications
pushUserNotifications,
init
};
};