Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(zendesk): lower concurrency to 3 for fetching ticket comments #8916

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions connectors/src/connectors/zendesk/temporal/activities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ModelId } from "@dust-tt/types";
import _ from "lodash";

import { isNodeZendeskForbiddenError } from "@connectors/connectors/zendesk/lib/errors";
import { syncArticle } from "@connectors/connectors/zendesk/lib/sync_article";
Expand Down Expand Up @@ -434,10 +435,20 @@ export async function syncZendeskTicketBatchActivity({

const users = await zendeskApiClient.users.list();

const res = await concurrentExecutor(
const comments = await concurrentExecutor(
tickets,
async (ticket) => {
const comments = await zendeskApiClient.tickets.getComments(ticket.id);
async (ticket) => zendeskApiClient.tickets.getComments(ticket.id),
{ concurrency: 3, onBatchComplete: heartbeat }
);

const res = await concurrentExecutor(
_.zip(tickets, comments),
async ([ticket, comments]) => {
if (!ticket || !comments) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are technically | undefined as there's no typescript guarantee that both arrays are equal size

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC: do you prefer this over a map over the tickets to turn them into objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter like this but I don't have a strong opinion really

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair 👍

throw new Error(
`[Zendesk] Unreachable: Ticket or comments not found, ticket: ${ticket}, comments: ${comments}`
);
}

return syncTicket({
connectorId,
Expand Down