From 9c4ac310d1f1d6942be933ec3b222d4cee9d3dcd Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Wed, 27 Nov 2024 11:22:15 +0100 Subject: [PATCH] fix(zendesk): only fetch comment authors (#8935) Co-authored-by: Henry Fontanier --- .../src/connectors/zendesk/temporal/activities.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/connectors/src/connectors/zendesk/temporal/activities.ts b/connectors/src/connectors/zendesk/temporal/activities.ts index 3039a22fbe378..e98cac6c97a44 100644 --- a/connectors/src/connectors/zendesk/temporal/activities.ts +++ b/connectors/src/connectors/zendesk/temporal/activities.ts @@ -434,16 +434,18 @@ export async function syncZendeskTicketBatchActivity({ return { hasMore: false, nextLink: "" }; } - const users = (await zendeskApiClient.users.list()) || []; - - const comments = await concurrentExecutor( + const comments2d = await concurrentExecutor( tickets, async (ticket) => zendeskApiClient.tickets.getComments(ticket.id), { concurrency: 3, onBatchComplete: heartbeat } ); + const userIds = _.uniq( + _.flatten(comments2d.map((comments) => comments.map((c) => c.author_id))) + ); + const { result: users } = await zendeskApiClient.users.showMany(userIds); const res = await concurrentExecutor( - _.zip(tickets, comments), + _.zip(tickets, comments2d), async ([ticket, comments]) => { if (!ticket || !comments) { throw new Error(