From ec930d79241d3775f2cec41b539fca800761f09c Mon Sep 17 00:00:00 2001 From: Aashish John Date: Tue, 27 Aug 2024 11:01:32 -0400 Subject: [PATCH] fix: wrap chunk tasks as progress tasks --- src/server/tasks/utils.ts | 13 +++++++++++++ src/server/worker.ts | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/server/tasks/utils.ts b/src/server/tasks/utils.ts index fa2f85c12..3a0428046 100644 --- a/src/server/tasks/utils.ts +++ b/src/server/tasks/utils.ts @@ -113,6 +113,8 @@ export interface ProgressTaskOptions { removeOnComplete: boolean; } +export type ProgressTaskList

= Record>; + export const wrapProgressTask =

( task: ProgressTask

, options: ProgressTaskOptions @@ -155,3 +157,14 @@ export const wrapProgressTask =

( throw err; } }; + +export const wrapProgressTaskList = async

( + list: ProgressTaskList

+) => { + return Object.entries(list).reduce((acc, [key, task]) => { + acc[key] = wrapProgressTask(task, { + removeOnComplete: true + }); + return acc; + }, {} as ProgressTaskList

); +}; diff --git a/src/server/worker.ts b/src/server/worker.ts index 85bdb3511..927538aa2 100644 --- a/src/server/worker.ts +++ b/src/server/worker.ts @@ -62,7 +62,7 @@ import syncContactQuestionResponse from "./tasks/sync-contact-question-response" import syncSlackTeamMembers from "./tasks/sync-slack-team-members"; import { trollPatrol, trollPatrolForOrganization } from "./tasks/troll-patrol"; import updateOrgMessageUsage from "./tasks/update-org-message-usage"; -import { wrapProgressTask } from "./tasks/utils"; +import { wrapProgressTask, wrapProgressTaskList } from "./tasks/utils"; const logFactory: LogFunctionFactory = (scope) => (level, message, meta) => logger.log({ level, message, ...meta, ...scope }); @@ -110,7 +110,7 @@ export const getWorker = async (attempt = 0): Promise => { [exportOptOutsIdentifier]: exportOptOuts, ...ngpVanTaskList, ...campaignBuilderTaskList, - ...chunkTaskList + ...wrapProgressTaskList(chunkTaskList) }; if (!workerSemaphore) {