diff --git a/src/services/memberActivity.service.ts b/src/services/memberActivity.service.ts index c5da1ba4..7aba4199 100644 --- a/src/services/memberActivity.service.ts +++ b/src/services/memberActivity.service.ts @@ -899,6 +899,7 @@ type memberInteractionType = { id: string, radius: number, stats: NodeStats } & type memberInteractionsGraphResponseType = { width: number, from: memberInteractionType, to: memberInteractionType }[] async function getMembersInteractionsNetworkGraph(guildId: string, guildConnection: Connection): Promise { // TODO: refactor function later + const usersInNetworkGraph: string[] = [] // userInteraction const usersInteractionsQuery = ` MATCH () -[r:INTERACTED_WITH {guildId: "${guildId}"}]-() @@ -919,6 +920,8 @@ async function getMembersInteractionsNetworkGraph(guildId: string, guildConnecti const rWeeklyInteraction = r?.properties?.weight as number const bUserId = b?.properties?.userId as string + usersInNetworkGraph.push(aUserId) + usersInNetworkGraph.push(bUserId) const interaction = { aUserId, bUserId, @@ -967,8 +970,9 @@ async function getMembersInteractionsNetworkGraph(guildId: string, guildConnecti }) // usersInfo - const usersInfo = await guildConnection.models.GuildMember.find() - const roles = await roleService.getRoles(guildConnection, {}) + const usersInfo = await guildConnection.models.GuildMember.find({ discordIds: { $in: usersInNetworkGraph } }); + const rolesInNetworkGraph = usersInfo.flatMap((user) => user.roles) + const roles = await roleService.getRoles(guildConnection, { roleId: { $in: rolesInNetworkGraph } }) // prepare data const response = usersInteractions.flatMap((interaction) => {