-
Notifications
You must be signed in to change notification settings - Fork 130
feat(entitlement): Introduce subscription override #4022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
375f594
to
ce537f7
Compare
ce537f7
to
00eaef6
Compare
31c535c
to
b291603
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't finished the review. Will come back on it after a break but I'm sending the comments I already have.
db/migrate/20250630180000_create_entitlement_features_and_privileges.rb
Outdated
Show resolved
Hide resolved
app/controllers/api/v1/subscriptions/entitlements/privileges_controller.rb
Outdated
Show resolved
Hide resolved
app/controllers/api/v1/subscriptions/entitlements/privileges_controller.rb
Outdated
Show resolved
Hide resolved
spec/requests/api/v1/subscriptions/entitlements_controller_spec.rb
Outdated
Show resolved
Hide resolved
app/serializers/v1/entitlement/subscription_entitlements_collection_serializer.rb
Show resolved
Hide resolved
db/migrate/20250717150000_add_subscription_external_id_to_entitlements.rb
Outdated
Show resolved
Hide resolved
db/migrate/20250717150000_add_subscription_external_id_to_entitlements.rb
Outdated
Show resolved
Hide resolved
app/services/entitlement/subscription_entitlement_destroy_service.rb
Outdated
Show resolved
Hide resolved
app/services/entitlement/subscription_entitlement_privilege_destroy_service.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great, nice work! The most important feedback are the ones about DB, the rest are mostly polish.
spec/requests/api/v1/subscriptions/entitlements_controller_spec.rb
Outdated
Show resolved
Hide resolved
app/services/entitlement/subscription_entitlements_update_service.rb
Outdated
Show resolved
Hide resolved
b291603
to
ee5e1ed
Compare
ee5e1ed
to
ba695a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was quite a big one 😄 Nice job!
Context
Plans have Features and Privileges but it's possible to override them at the subscription level.
The tough part is that a feature can have no privilege, it can be part of the plan, but removed from the subscription. This is why we need the
SubscriptionFeatureRemoval
models.Description
The View
In order to provide the full details of the subscriptions entitlements (plan entitlements + subscription overrides - subscription removals) we create a database view and a read only models, which allows use to query one table to get all the info.
The details are serialized as a collection (because it's one line per privilege but it needs to be grouped by feature to form the correct object.
New endpoints