Exclude namespace-banned users from being counted as billable members
What does this MR do and why?
- Resolves https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/203
- Excludes members that are banned in a namespace from being counted as billable members
Screenshots or screen recordings
Screen_Recording_2023-03-12_at_9.03.16_pm
How to set up and validate locally
- Add any user as a member to a parent group, eg.
Gitlab Org
onhttp://localhost:3000/groups/gitlab-org/-/group_members
- Calculate the number of billed users for that namespace. The user you just added should be included in that response
bundle exec rails c
> billed_users = Namespace.find_by(name: 'Gitlab Org').billed_user_ids[:user_ids].count
> billed_users[:user_ids].count
> reload!
- Ban the user from that namespace.
- The user would have now moved to the
Banned
section on the members page,http://localhost:3000/groups/gitlab-org/-/group_members?tab=banned
- Calculate the billed members of that namespace again. The user you just banned should be excluded from that result.
Query Plans with gitlab-org namespace
Method | Buffers (current) | Buffers (with this query) |
---|---|---|
billed_group_users | 32357 | 32363 |
billed_project_users | 19083 | 24460 |
billed_shared_group_users | 32484 | 33176 |
billed_invited_group_to_project_users | 47875 | 49338 |
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Hinam Mehra