Skip to content

Commit 3a58d0b

Browse files
committed
feat:resolved issue of inefficient array operation chaining
1 parent e25ea27 commit 3a58d0b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

models/discordactions.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,14 @@ const enrichGroupDataWithMembershipInfo = async (discordId, groups = []) => {
325325
})
326326
);
327327

328-
const usersInDiscordSet = new Set(
329-
usersSnapshots
330-
.flat()
331-
.filter((user) => user?.roles?.in_discord === true)
332-
.map((user) => user.discordId)
333-
);
328+
const usersInDiscordSet = new Set();
329+
for (const userList of usersSnapshots) {
330+
for (const user of userList) {
331+
if (user?.roles?.in_discord === true) {
332+
usersInDiscordSet.add(user.discordId);
333+
}
334+
}
335+
}
334336

335337
const roleIdToCountMap = {};
336338
groupsToUserMappings.forEach((mapping) => {

0 commit comments

Comments
 (0)