-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
feat: add endpoints groups.membersOrderedByRole channels.membersOrderedByRole #34153
base: develop
Are you sure you want to change the base?
feat: add endpoints groups.membersOrderedByRole channels.membersOrderedByRole #34153
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: e8d16bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
4a3be37
to
aa02c7a
Compare
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #34153 +/- ##
===========================================
- Coverage 75.83% 75.27% -0.57%
===========================================
Files 511 516 +5
Lines 22171 22532 +361
Branches 5397 5485 +88
===========================================
+ Hits 16813 16960 +147
- Misses 4710 4911 +201
- Partials 648 661 +13
Flags with carried forward coverage won't be shown. Click here to find out more. |
7c92475
to
df876a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could create a rooms.membersOrderedByRole
instead of creating one for each room type.
Also, we need to create some mock data to test the aggregation part and its performance.
@ricardogarim can you help us with that.
packages/rest-typings/src/v1/groups/GroupsMembersByOrderedRole.ts
Outdated
Show resolved
Hide resolved
packages/rest-typings/src/v1/channels/ChannelsMembersByOrderedRole.ts
Outdated
Show resolved
Hide resolved
ae9d2e1
to
c5fa198
Compare
@@ -3647,4 +3648,179 @@ describe('[Rooms]', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
describe('[/rooms.membersOrderedByRole]', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test cases for:
- Trying to fetch a private room by a user not part of room
- Trying to fetch a public room by a user not part of room
- The same 2, but with users that are part of the rooms
- Trying to fetch a private channel inside a public team for someone not part of the room
- Trying to fetch a public channel inside a private team for someone not part of the room
- The same 2, but with users that are part of the rooms
Just to ensure we don't show more data than what we should 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the following tests:
[Rooms]
[/rooms.membersOrderedByRole]
✔ should return a list of members ordered by owner, moderator, then members by default
✔ should allow custom role order
✔ should support pagination
✔ should return matched members when using filter param
✔ should return empty list if no matches (e.g., filter by status that no one has)
✔ should support custom sorting by username descending
Additional Visibility Tests
✔ should not fetch private room members by user not part of room
✔ should fetch private room members by user who is part of the room
✔ should fetch public room members by user who is part of the room
✔ should fetch public room members by user not part of room - because public (135ms)
✔ should fetch a private channel members inside a public team by someone part of the room
✔ should not fetch a private channel members inside a public team by someone not part of the room, but part of team
✔ should not fetch a private channel members inside a public team by someone not part of the team
✔ should fetch a public channel members inside a public team by someone part of the room
✔ should fetch a public channel members inside a public team by someone not part of the room, but part of team
✔ should fetch a public channel members inside a public team by someone not part of the team
✔ should fetch a public channel members inside a private team by someone part of the room
✔ should fetch a public channel members inside a private team by someone not part of the room, but part of team
✔ should not fetch a public channel members inside a private team by someone not part of team
✔ should fetch a private channel members inside a private team by someone part of the room
✔ should not fetch a private channel members inside a private team by someone not part of the room, but part of team
✔ should not fetch a private channel members inside a private team by someone not part of team
}, | ||
]; | ||
|
||
const [result] = await Subscriptions.col.aggregate(facetPipeline, { allowDiskUse: true }).toArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcosSpessatto , should we run this on the secondary like the other aggregations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense
roles: IRole['_id'][]; | ||
}; | ||
|
||
export async function findUsersOfRoomOrderedByRole({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some explains with some decent amount of data to check on the perf of the aggregation? :please:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me, we just need to do some perf tests with some fake data to ensure the query perf
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
6ceb8e3
to
e8d16bf
Compare
Proposed changes (including videos or screenshots)
Adds
groups.membersOrderedByRole
andchannels.membersOrderedByRole
endpoints to retrieve members of groups and channels sorted according to their respective role in the room.This will help in grouping of users according to their roles in the room like below.
The endpoint works similar as groups.members and channels.members, but accepts an optional rolesOrder[] param which can be used for defining roles order while sorting. The index of the role will signify its priority. By default, owner > moderator > rest of members.
A sample request
Issue(s)
Steps to test or reproduce
Further comments
CORE-846