Skip to content

Commit be33819

Browse files
committed
fix(api-v2): use select for user/owner relations in teams event types repo
Replace include: { users: true } with explicit selects across all 7 queries in teams-event-types.repository.ts. Only fetches User fields actually needed by the API output service instead of all 50+ scalar fields. Also applies same pattern to owner and children relations. Refs #29513
1 parent d1ad4ea commit be33819

1 file changed

Lines changed: 109 additions & 7 deletions

File tree

apps/api/v2/src/modules/teams/event-types/teams-event-types.repository.ts

Lines changed: 109 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ export class TeamsEventTypesRepository {
1717
teamId,
1818
},
1919
include: {
20-
users: true,
20+
users: {
21+
select: {
22+
id: true,
23+
name: true,
24+
username: true,
25+
avatarUrl: true,
26+
brandColor: true,
27+
darkBrandColor: true,
28+
weekStart: true,
29+
metadata: true,
30+
isPlatformManaged: true,
31+
organizationId: true,
32+
},
33+
},
2134
schedule: true,
2235
hosts: true,
2336
destinationCalendar: true,
@@ -35,7 +48,20 @@ export class TeamsEventTypesRepository {
3548
},
3649
},
3750
include: {
38-
users: true,
51+
users: {
52+
select: {
53+
id: true,
54+
name: true,
55+
username: true,
56+
avatarUrl: true,
57+
brandColor: true,
58+
darkBrandColor: true,
59+
weekStart: true,
60+
metadata: true,
61+
isPlatformManaged: true,
62+
organizationId: true,
63+
},
64+
},
3965
schedule: true,
4066
hosts: hostsLimit
4167
? {
@@ -79,7 +105,29 @@ export class TeamsEventTypesRepository {
79105
slug: eventTypeSlug,
80106
},
81107
},
82-
include: { owner: true, team: true },
108+
include: {
109+
owner: {
110+
select: {
111+
id: true,
112+
email: true,
113+
name: true,
114+
username: true,
115+
timeZone: true,
116+
weekStart: true,
117+
avatarUrl: true,
118+
locale: true,
119+
defaultScheduleId: true,
120+
brandColor: true,
121+
darkBrandColor: true,
122+
metadata: true,
123+
hideBranding: true,
124+
theme: true,
125+
organizationId: true,
126+
isPlatformManaged: true,
127+
},
128+
},
129+
team: true,
130+
},
83131
});
84132
}
85133

@@ -90,7 +138,20 @@ export class TeamsEventTypesRepository {
90138
},
91139
...(sortCreatedAt && { orderBy: { id: sortCreatedAt } }),
92140
include: {
93-
users: true,
141+
users: {
142+
select: {
143+
id: true,
144+
name: true,
145+
username: true,
146+
avatarUrl: true,
147+
brandColor: true,
148+
darkBrandColor: true,
149+
weekStart: true,
150+
metadata: true,
151+
isPlatformManaged: true,
152+
organizationId: true,
153+
},
154+
},
94155
schedule: true,
95156
hosts: true,
96157
destinationCalendar: true,
@@ -115,7 +176,20 @@ export class TeamsEventTypesRepository {
115176
return this.dbRead.prisma.eventType.findUnique({
116177
where: { id: eventTypeId },
117178
include: {
118-
users: true,
179+
users: {
180+
select: {
181+
id: true,
182+
name: true,
183+
username: true,
184+
avatarUrl: true,
185+
brandColor: true,
186+
darkBrandColor: true,
187+
weekStart: true,
188+
metadata: true,
189+
isPlatformManaged: true,
190+
organizationId: true,
191+
},
192+
},
119193
schedule: true,
120194
hosts: true,
121195
destinationCalendar: true,
@@ -127,14 +201,42 @@ export class TeamsEventTypesRepository {
127201
async getEventTypeChildren(eventTypeId: number) {
128202
return this.dbRead.prisma.eventType.findMany({
129203
where: { parentId: eventTypeId },
130-
include: { users: true, schedule: true, hosts: true, destinationCalendar: true },
204+
include: {
205+
users: {
206+
select: {
207+
id: true,
208+
name: true,
209+
username: true,
210+
avatarUrl: true,
211+
brandColor: true,
212+
darkBrandColor: true,
213+
weekStart: true,
214+
metadata: true,
215+
isPlatformManaged: true,
216+
organizationId: true,
217+
},
218+
},
219+
schedule: true,
220+
hosts: true,
221+
destinationCalendar: true,
222+
},
131223
});
132224
}
133225

134226
async getEventTypeByIdWithChildren(eventTypeId: number) {
135227
return this.dbRead.prisma.eventType.findUnique({
136228
where: { id: eventTypeId },
137-
include: { children: true },
229+
include: {
230+
children: {
231+
select: {
232+
id: true,
233+
userId: true,
234+
slug: true,
235+
title: true,
236+
parentId: true,
237+
},
238+
},
239+
},
138240
});
139241
}
140242

0 commit comments

Comments
 (0)