-
Notifications
You must be signed in to change notification settings - Fork 4
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
#40 - ignore non zero included price quantities #41
base: main
Are you sure you want to change the base?
Conversation
.billing_subscriptions | ||
.active | ||
.flat_map(&:included_prices) | ||
.select{ |included_price| included_price.quantity && included_price.quantity > 0 } |
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 would have added a scope, but I am worried about repos like CF that have already cloned the starter repo. I.e. if I were to deploy a new scope, and upgrade CF, everything would break because we override the IncludedPrice model, and there would be no scope definition in there.
@@ -8,7 +8,7 @@ def self.all_products | |||
end | |||
|
|||
def current_products | |||
products = parent.team.billing_subscriptions.active.map(&:included_prices).flatten.map(&:price).map(&:product) | |||
products = non_zero_included_prices.map(&:price).compact.map(&:product).compact |
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 added these compacts to prevent breakages in the event of a dev or someone removing a product or price from the products.yml
.billing_subscriptions | ||
.active | ||
.flat_map(&:included_prices) | ||
.select { |included_price| included_price.quantity && included_price.quantity > 0 } |
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 would have added a scope, but I am worried about repos like CF that have already cloned the starter repo. I.e. if I were to deploy a new scope, and upgrade CF, everything would break because we override the IncludedPrice model, and there would be no scope definition in there.
Would love to add a spec, but it is not possible to test this class in this repo alone. I decided to run some local tests in the CF repo to make sure this change did as it is supposed to.
closes #40