From e4157745122ee77e56d2015e4eb8403832084c6c Mon Sep 17 00:00:00 2001 From: Aubin <60398825+aubin-tchoi@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:46:04 +0100 Subject: [PATCH] [connectors] Fix timeouts when syncing Zendesk articles (#8843) * perf: only fetch sections for the category when syncing articles * perf: only fetch the necessary users when syncing articles --- connectors/src/@types/node-zendesk.d.ts | 3 +++ connectors/src/connectors/zendesk/temporal/activities.ts | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/connectors/src/@types/node-zendesk.d.ts b/connectors/src/@types/node-zendesk.d.ts index c030b65f4e9b..f857a1a2a5b1 100644 --- a/connectors/src/@types/node-zendesk.d.ts +++ b/connectors/src/@types/node-zendesk.d.ts @@ -208,6 +208,9 @@ declare module "node-zendesk" { }; sections: { list: () => Promise; + listByCategory: ( + categoryId: number + ) => Promise; show: ( sectionId: number ) => Promise<{ response: Response; result: ZendeskFetchedSection }>; diff --git a/connectors/src/connectors/zendesk/temporal/activities.ts b/connectors/src/connectors/zendesk/temporal/activities.ts index 0edc9f412c61..f9cdfdb1ea7e 100644 --- a/connectors/src/connectors/zendesk/temporal/activities.ts +++ b/connectors/src/connectors/zendesk/temporal/activities.ts @@ -331,8 +331,11 @@ export async function syncZendeskArticleBatchActivity({ `[Zendesk] Processing ${articles.length} articles in batch` ); - const sections = await zendeskApiClient.helpcenter.sections.list(); - const users = await zendeskApiClient.users.list(); + const sections = + await zendeskApiClient.helpcenter.sections.listByCategory(categoryId); + const { result: users } = await zendeskApiClient.users.showMany( + articles.map((article) => article.author_id) + ); await concurrentExecutor( articles,