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

204 adding more fileds for guild member for network graph api #206

8 changes: 7 additions & 1 deletion __tests__/fixtures/guildMember.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const guildMemberThree = {
joinedAt: new Date("2022-06-01"),
isBot: false,
discriminator: "0",
nickname: null,
globalName: null
};

export const guildMemberFour = {
Expand All @@ -42,6 +44,8 @@ export const guildMemberFour = {
joinedAt: new Date("2023-04-01"),
isBot: false,
discriminator: "4321",
nickname: null,
globalName: null
};

export const guildMemberFive = {
Expand All @@ -51,7 +55,9 @@ export const guildMemberFive = {
roles: ["652345789987654321"],
joinedAt: new Date("2023-04-08"),
isBot: false,
discriminator: "4321"
discriminator: "4321",
nickname: null,
globalName: null
};

export const insertGuildMembers = async function <Type>(guildMembers: Array<Type>, connection: Connection) {
Expand Down
56 changes: 40 additions & 16 deletions __tests__/integration/memberActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ describe('member-activity routes', () => {
expect(Array.isArray(res.body)).toBe(true);
expect(res.body).toHaveLength(2)
expect(res.body).toEqual(expect.arrayContaining([({
from: { id: '123456789', radius: 3, username: 'behzad_rabiei', stats: "SENDER" },
to: { id: '987654321', radius: 3, username: 'mrjackalop', stats: "RECEIVER" },
from: { avatar: null, id: "123456789", joinedAt: "2023-03-07T00:00:00.000Z", ngu: "Behzad", radius: 3, roles: [], stats: "SENDER", username: "behzad_rabiei" },
to: { avatar: "AvatarLink", id: "987654321", joinedAt: "2023-03-31T00:00:00.000Z", ngu: "Daniel", radius: 3, roles: [], stats: "RECEIVER", username: "mrjackalop"},
width: 1
})
]))
expect(res.body).toEqual(expect.arrayContaining([({
from: { id: '987654321', radius: 3, username: 'mrjackalop', stats: "RECEIVER" },
to: { id: '123456789', radius: 3, username: 'behzad_rabiei', stats: "SENDER" },
from: { avatar: "AvatarLink", id: "987654321", joinedAt: "2023-03-31T00:00:00.000Z", ngu: "Daniel", radius: 3, roles: [], stats: "RECEIVER", username: "mrjackalop"},
to: { avatar: null, id: "123456789", joinedAt: "2023-03-07T00:00:00.000Z", ngu: "Behzad", radius: 3, roles: [], stats: "SENDER", username: "behzad_rabiei"},
width: 2
})
]))
Expand Down Expand Up @@ -764,7 +764,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberThree.joinedAt.toISOString(),
discriminator: guildMemberThree.discriminator,
activityComposition: ['Newly active']
activityComposition: ['Newly active'],
nickname: guildMemberThree.nickname,
globalName: guildMemberThree.globalName
});

expect(res.body.results[1]).toEqual({
Expand All @@ -779,7 +781,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberOne.joinedAt.toISOString(),
discriminator: guildMemberOne.discriminator,
activityComposition: ['Newly active', 'Became disengaged']
activityComposition: ['Newly active', 'Became disengaged'],
nickname: guildMemberOne.nickname,
globalName: guildMemberOne.globalName
});

expect(res.body.results[2]).toEqual({
Expand All @@ -793,7 +797,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberTwo.joinedAt.toISOString(),
discriminator: guildMemberTwo.discriminator,
activityComposition: ['Newly active']
activityComposition: ['Newly active'],
nickname: guildMemberTwo.nickname,
globalName: guildMemberTwo.globalName
});

expect(res.body.results[3]).toEqual({
Expand All @@ -805,7 +811,9 @@ describe('member-activity routes', () => {
{ roleId: role1.roleId, name: role1.name, color: role1.color }],
joinedAt: guildMemberFour.joinedAt.toISOString(),
discriminator: guildMemberFour.discriminator,
activityComposition: ['Others']
activityComposition: ['Others'],
nickname: guildMemberFour.nickname,
globalName: guildMemberFour.globalName
});
})

Expand Down Expand Up @@ -1147,7 +1155,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberThree.joinedAt.toISOString(),
discriminator: guildMemberThree.discriminator,
activityComposition: ['Newly active', 'Dropped']
activityComposition: ['Newly active', 'Dropped'],
nickname: guildMemberThree.nickname,
globalName: guildMemberThree.globalName
});

expect(res.body.results[1]).toEqual({
Expand All @@ -1162,7 +1172,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberOne.joinedAt.toISOString(),
discriminator: guildMemberOne.discriminator,
activityComposition: ['Newly active', 'Joined', 'Dropped']
activityComposition: ['Newly active', 'Joined', 'Dropped'],
nickname: guildMemberOne.nickname,
globalName: guildMemberOne.globalName
});

expect(res.body.results[2]).toEqual({
Expand All @@ -1176,7 +1188,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberTwo.joinedAt.toISOString(),
discriminator: guildMemberTwo.discriminator,
activityComposition: ['Newly active', 'Dropped']
activityComposition: ['Newly active', 'Dropped'],
nickname: guildMemberTwo.nickname,
globalName: guildMemberTwo.globalName
});

expect(res.body.results[3]).toEqual({
Expand All @@ -1189,7 +1203,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberFour.joinedAt.toISOString(),
discriminator: guildMemberFour.discriminator,
activityComposition: ['Others']
activityComposition: ['Others'],
nickname: guildMemberFour.nickname,
globalName: guildMemberFour.globalName
});
})

Expand Down Expand Up @@ -1531,7 +1547,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberThree.joinedAt.toISOString(),
discriminator: guildMemberThree.discriminator,
activityComposition: ['Were newly active']
activityComposition: ['Were newly active'],
nickname: guildMemberThree.nickname,
globalName: guildMemberThree.globalName
});

expect(res.body.results[1]).toEqual({
Expand All @@ -1546,7 +1564,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberOne.joinedAt.toISOString(),
discriminator: guildMemberOne.discriminator,
activityComposition: ['Became disengaged', 'Were newly active', 'Were consistenly active']
activityComposition: ['Became disengaged', 'Were newly active', 'Were consistenly active'],
nickname: guildMemberOne.nickname,
globalName: guildMemberOne.globalName
});

expect(res.body.results[2]).toEqual({
Expand All @@ -1560,7 +1580,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberTwo.joinedAt.toISOString(),
discriminator: guildMemberTwo.discriminator,
activityComposition: ['Were newly active']
activityComposition: ['Were newly active'],
nickname: guildMemberTwo.nickname,
globalName: guildMemberTwo.globalName
});

expect(res.body.results[3]).toEqual({
Expand All @@ -1573,7 +1595,9 @@ describe('member-activity routes', () => {
],
joinedAt: guildMemberFour.joinedAt.toISOString(),
discriminator: guildMemberFour.discriminator,
activityComposition: ['Others']
activityComposition: ['Others'],
nickname: guildMemberFour.nickname,
globalName: guildMemberFour.globalName
});
})

Expand Down
21 changes: 18 additions & 3 deletions src/controllers/memberActivity.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ const activeMembersCompositionTable = catchAsync(async function (req: IAuthReque
const guildMembers = await guildMemberService.queryGuildMembers(connection, filter, options, memberActivity, activityCompostionsTypes.activeMembersComposition);
const roles = await roleService.getRoles(connection, {});
if (guildMembers) {
guildMemberService.addNeededDataForTable(guildMembers.results, roles, memberActivity, filter.activityComposition);
guildMembers.results.forEach((guildMember) => {
guildMember.roles = roleService.getRolesForGuildMember(guildMember, roles);
guildMember.ngu = guildMemberService.getNgu(guildMember);
guildMember.activityComposition = memberActivityService.getActivityComposition(guildMember, memberActivity, filter.activityComposition);
guildMember.username = guildMemberService.getUsername(guildMember);
});
}
await closeConnection(connection)
res.send(guildMembers);
Expand All @@ -118,7 +123,12 @@ const activeMembersOnboardingTable = catchAsync(async function (req: IAuthReques
const guildMembers = await guildMemberService.queryGuildMembers(connection, filter, options, memberActivity, activityCompostionsTypes.activeMembersOnboarding);
const roles = await roleService.getRoles(connection, {});
if (guildMembers) {
guildMemberService.addNeededDataForTable(guildMembers.results, roles, memberActivity, filter.activityComposition);
guildMembers.results.forEach((guildMember) => {
guildMember.roles = roleService.getRolesForGuildMember(guildMember, roles);
guildMember.ngu = guildMemberService.getNgu(guildMember);
guildMember.activityComposition = memberActivityService.getActivityComposition(guildMember, memberActivity, filter.activityComposition);
guildMember.username = guildMemberService.getUsername(guildMember);
});
}
await closeConnection(connection)
res.send(guildMembers);
Expand All @@ -136,7 +146,12 @@ const disengagedMembersCompositionTable = catchAsync(async function (req: IAuthR
const guildMembers = await guildMemberService.queryGuildMembers(connection, filter, options, memberActivity, activityCompostionsTypes.disengagedMembersCompostion);
const roles = await roleService.getRoles(connection, {});
if (guildMembers) {
guildMemberService.addNeededDataForTable(guildMembers.results, roles, memberActivity, filter.activityComposition);
guildMembers.results.forEach((guildMember) => {
guildMember.roles = roleService.getRolesForGuildMember(guildMember, roles);
guildMember.ngu = guildMemberService.getNgu(guildMember);
guildMember.activityComposition = memberActivityService.getActivityComposition(guildMember, memberActivity, filter.activityComposition);
guildMember.username = guildMemberService.getUsername(guildMember);
});
}
await closeConnection(connection)
res.send(guildMembers);
Expand Down
70 changes: 69 additions & 1 deletion src/docs/memberActivity.doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,31 @@ paths:
type: string
stats:
type: string
avatar:
type: string
example: "b50adff099924dd5e6b72d13f77eb9d7"
joinedAt:
type: string
format: date-time
example: "2022-05-30T15:46:52.924+00:00"
roles:
type: array
items:
type: object
properties:
roleId:
type: string
example: "discordRoleId1"
name:
type: string
example: "role1"
color:
type: string
example: "#000000"
ngu:
type: string
example: "HajBehzadTalast"

to:
type: object
properties:
Expand All @@ -269,8 +294,33 @@ paths:
type: integer
username:
type: string
stats:
stats:
type: string
avatar:
type: string
example: "b50adff099924dd5e6b72d13f77eb9d7"
joinedAt:
type: string
format: date-time
example: "2022-05-30T15:46:52.924+00:00"
roles:
type: array
items:
type: object
properties:
roleId:
type: string
example: "discordRoleId1"
name:
type: string
example: "role1"
color:
type: string
example: "#000000"
ngu:
type: string
example: "HajBehzadTalast"

width:
type: integer
"401":
Expand Down Expand Up @@ -537,6 +587,12 @@ paths:
ngu:
type: string
example: "Behzad"
nickname:
type: string
example: "Behzad"
globalName:
type: string
example: "Behzad"
avatar:
type: string
example: "b50adff099924dd5e6b72d13f77eb9d7"
Expand Down Expand Up @@ -665,6 +721,12 @@ paths:
ngu:
type: string
example: "Behzad"
nickname:
type: string
example: "Behzad"
globalName:
type: string
example: "Behzad"
avatar:
type: string
example: "b50adff099924dd5e6b72d13f77eb9d7"
Expand Down Expand Up @@ -793,6 +855,12 @@ paths:
ngu:
type: string
example: "Behzad"
nickname:
type: string
example: "Behzad"
globalName:
type: string
example: "Behzad"
avatar:
type: string
example: "b50adff099924dd5e6b72d13f77eb9d7"
Expand Down
Loading