Create service to calculate the seat count usage
What does this MR do and why?
- Part of [SaaS] Alert to group Owners when group is appr... (#348481 - closed)
- Split from Plug in all logic to display Seat Count Alert (!79563 - merged) as it was getting quite large.
Create a service that will determine if the user should be shown seat usage alerts and, if so, return the data required to populate the alert.
This issue is to be followed up by the frontend changes required to actually display the alert (Plug in all logic to display Seat Count Alert (!79563 - merged))
What triggers the alert?
When a user is added that increases the number of Max seats used
:
- If
Max seats used
<Seats in subscription
, trigger the alert based on the percentage ofSeats currently in use
/Seats in subscription
per the table below - If
Max seats used
>=Seats in subscription
, the alert should not be triggered.
Seats in subscription | Notified at |
---|---|
0-15 | No percentage, notify at 1 seat left |
16-25 | No percentage, notify at 2 seats left |
26-99 | 10 % |
100-999 | 8% |
1000+ | 5% |
How to set up and validate locally
Have both Gitlab and the CustomersDot instance running. The GDK should be running with GITLAB_SIMULATE_SAAS=1
- Ensure the instance thinks it's SaaS
ApplicationSetting.first.update!(check_namespace_plan: true)
- Purchase a subscription for a group with three seats
- Update the namespace statistics
UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
- Run the service from the console and verify that
nil
is returnedGitlabSubscriptions::Reconciliations::CalculateSeatCountDataService.new(namespace: group, user: group.owners.first).execute
- Add a developer to the group
- Update the namespace statistics
UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
- Run the service from the console and verify that data is returned
GitlabSubscriptions::Reconciliations::CalculateSeatCountDataService.new(namespace: group, user: group.owners.first).execute
Intended alert UI
Implementing the UI is part of !79563 (merged)
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 Josianne Hyson