Exclude expired subscriptions from seat count usage alerts
What does this MR do and why?
Part of: #348481 (closed)
Update the logic on when to show the seat count usage alerts to;
- Exclude trial subscriptions
- Exclude expired subscriptions
- Cache
nil
responses from fetching the subscription on CustomersDot (ie, there is no active subscription)
This will reduce the number of useless calls CustomersDot which will help the pages that this alert is rendered on load faster.
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
- Create a new group with one member
- Purchase a subscription for the group with three seats
- Enable the feature flag for the group
Feature.enable(:seat_count_alerts, group)
- Add a developer to the group
- Update the namespace statistics
UpdateMaxSeatsUsedForGitlabComSubscriptionsWorker.new.perform
- View the group homepage - the alert should be displayed
- Clear the cached result
Rails.cache.delete("subscription:eligible_for_seat_usage_alerts:namespace:#{gitlab_subscription.cache_key}")
- In the CustomersDot console, delete the
Order
record for the corresponding subscription (to test no-subscription, or future dated subscription in CustomersDot case) - Reload the group homepage - alert should not be displayed and there should be a log of the graphql
eligibleForSeatUsageAlerts
request in the CustomersDot console - Clear the cached result
Rails.cache.delete("subscription:eligible_for_seat_usage_alerts:namespace:#{gitlab_subscription.cache_key}")
- Expire the subscription (to test the expired subscription case)
gitlab_subscription.update!(start_date: 2.years.ago, end_date: 1.year.ago)
- Reload the group homepage - alert should not be displayed and there should not be a log of the graphql
eligibleForSeatUsageAlerts
request in the CustomersDot console
You can also create a trial subscription for a group, enable the feature flag and ensure there are no requests to CustomersDot.
Recording of the above steps:
Get alert to display:
CleanShot_2022-06-15_at_13.12.15-converted_4
Verify changes in this MR:
CleanShot_2022-06-15_at_13.12.15-converted_5
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