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

fix(zendesk): only fetch comment authors #8935

Merged
merged 1 commit into from
Nov 27, 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
10 changes: 6 additions & 4 deletions connectors/src/connectors/zendesk/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +442 to +445
Copy link
Contributor

Choose a reason for hiding this comment

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

wow I hate this lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whic part :p ?

Copy link
Contributor

Choose a reason for hiding this comment

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

i so deeply hate Lodash it's crazy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why ? it's pretty convenient.

WIthout lodash you'd need to do:

Array.from(new Set(comments2d.map((comments) => comments.map((c) => c.author_id)).flat()))

which in my opinion is less readable:

  • array.from + set is longer
  • mixing fn(...) with obj.meth(...) syntaxes on one line makes it harder to understand

debatable ofc, but we have lodash so we might as well use it

Copy link
Contributor

Choose a reason for hiding this comment

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

I would personally do const userIds = [...new Set(comments2d.flatMap(comments => comments.map(c => c.author_id)))];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's not bad !

Copy link
Contributor

Choose a reason for hiding this comment

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

matter of personal taste to me, I don't see lodash as smth cool kids do :p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see javascript as something the cool kids do

Copy link
Contributor

Choose a reason for hiding this comment

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

true lol

Copy link
Contributor

Choose a reason for hiding this comment

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

thank god we do rust


const res = await concurrentExecutor(
_.zip(tickets, comments),
_.zip(tickets, comments2d),
async ([ticket, comments]) => {
if (!ticket || !comments) {
throw new Error(
Expand Down