Skip to content

Create service to calculate the seat count usage

Josianne Hyson requested to merge jh-calculate_seat_count_usage into master

What does this MR do and why?

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 of Seats 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

  1. Ensure the instance thinks it's SaaS
    • ApplicationSetting.first.update!(check_namespace_plan: true)
  2. Purchase a subscription for a group with three seats
  3. Update the namespace statistics
    • UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
  4. Run the service from the console and verify that nil is returned
    • GitlabSubscriptions::Reconciliations::CalculateSeatCountDataService.new(namespace: group, user: group.owners.first).execute
  5. Add a developer to the group
  6. Update the namespace statistics
    • UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
  7. 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)

CleanShot_2022-03-22_at_16.28.38

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Josianne Hyson

Merge request reports