Introduce for_active_add_ons query scope
What does this MR do and why?
We are moving away from AvailableServices. In this class, we currently use the add_on_purchases helper to determine whether the add_on_names defined by this service have actually been purchased for the given instance or namespace.
In this MR, we:
- Move this logic into an API owned by groupprovision instead of groupcloud connector.
- Adjust the logic to better reflect the various requirements we have, such as:
- The namespace should only stick if we're actually on gitlab.com.
- Replace
self_and_ancestorwithroot_ancestorsince we do not attach billing records to sub-namespaces.
This change is behind the feature flag cloud_connector_new_purchase_lookup. In subsequent MRs, we will be replacing calls to the existing purchased? and add_on_purchases methods with this new API instead.
This change is primarily a refactor and not user-facing.
References
How to set up and validate locally
- In rails console run `Feature.enable(:cloud_connector_new_purchase_lookup)
- In rails console run
GitlabSubscriptions::AddOnPurchase.for_active_add_ons(['duo_core'])
- On self-managed: This should only return the
Duo Coreadd-on. - On gitlab.com: The result should be empty because no namespace is provided.
- With
namespace: <group>set: This should only return theDuo Coreadd-on.
- With
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #542422 (closed)
Edited by Matthias Käppler