Implementation: Show total group count for users in admin users table [Backend]
Problem to solve
Add a sum of Groups
to the Users
view in the Admin Area
.
This is expected to be much more complex than adding the sum of Projects
#249590 (closed) for the reasons outlined below in Additional notes
.
Parent epic: &4432 (closed)
Proposal
Show the truncated total number of authorized Groups
for each user.
Implementation outline
- Create a endpoint to get the truncated authorized
groups
count given an array of user IDs. Implemented in GraphQL (details below) -2
backend
GraphQL API
groupCount
for a set of users can be obtained by accessing the users
GraphQL endpoint.
Example request:
query {
users(usernames: ["asubramanian1", "mwoolf"]){
nodes{
id
avatarUrl
name
groupCount
}
}
}
Example request:
{
"data": {
"users": {
"nodes": [
{
"id": "gid://gitlab/User/1678249",
"avatarUrl": "https://secure.gravatar.com/avatar/4c8af02fcb6678db41bd8d3a29f9c1d8?s=80&d=identicon",
"name": "Max Woolf",
"groupCount": null
},
{
"id": "gid://gitlab/User/1675776",
"avatarUrl": "https://secure.gravatar.com/avatar/f2253d38808acfe769a32da952dbe91d?s=80&d=identicon",
"name": "Aishwarya Subramanian",
"groupCount": 18
}
]
}
}
}
Access
- Administrator users can access the group count of all users in the system.
- Non-administrator users can access the group count of only self
Feature Flag
The feature is gated behind the flag: user_group_counts
, and is disabled by default.
Additional notes
The additional complexity for group count is due to the performance concerns we've dicussed here and discovered in !39581 (comment 399390950), and the implementation is based on database and frontend maintainer feedback with the intent to get the page time below 100ms
by asynchronously loading the groups
count.