mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
perf: add p-limit to _getUsersAvailability to limit concurrent executions to 10 (#21374)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
[email protected] <[email protected]>
parent
d574840c3f
commit
6cb3bdc567
@@ -7,6 +7,7 @@ import type {
|
||||
EventType as PrismaEventType,
|
||||
} from "@prisma/client";
|
||||
import * as Sentry from "@sentry/nextjs";
|
||||
import pLimit from "p-limit";
|
||||
import { z } from "zod";
|
||||
|
||||
import type { Dayjs } from "@calcom/dayjs";
|
||||
@@ -699,22 +700,26 @@ type GetUsersAvailabilityProps = {
|
||||
};
|
||||
|
||||
const _getUsersAvailability = async ({ users, query, initialData }: GetUsersAvailabilityProps) => {
|
||||
const limit = pLimit(10);
|
||||
|
||||
return await Promise.all(
|
||||
users.map((user) =>
|
||||
_getUserAvailability(
|
||||
{
|
||||
...query,
|
||||
userId: user.id,
|
||||
username: user.username || "",
|
||||
},
|
||||
initialData
|
||||
? {
|
||||
...initialData,
|
||||
user,
|
||||
currentBookings: user.currentBookings,
|
||||
outOfOfficeDays: user.outOfOfficeDays,
|
||||
}
|
||||
: undefined
|
||||
limit(() =>
|
||||
_getUserAvailability(
|
||||
{
|
||||
...query,
|
||||
userId: user.id,
|
||||
username: user.username || "",
|
||||
},
|
||||
initialData
|
||||
? {
|
||||
...initialData,
|
||||
user,
|
||||
currentBookings: user.currentBookings,
|
||||
outOfOfficeDays: user.outOfOfficeDays,
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user