-
Notifications
You must be signed in to change notification settings - Fork 192
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
Refactor: Change unlimited capacity concept from 0 to null #7291
base: develop
Are you sure you want to change the base?
Conversation
return $value === 'null' ? null : absint($value); | ||
}, | ||
'validate_callback' => function ($value) { | ||
return $value === 'null' || rest_is_integer($value); |
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.
Why would the value be a string of 'null'
?
if ( ! isset($maxCapacitySales)) { | ||
$maxCapacitySales = array_reduce($ticketTypes, function (Money $carry, $ticketType) { | ||
return $carry->add($ticketType['price']->multiply($ticketType['capacity'])); | ||
}, new Money(0, give_get_currency())); | ||
|
||
$salesPercentage = $maxCapacitySales->formatToMinorAmount() > 0 ? max( | ||
min($salesTotal->formatToMinorAmount() / $maxCapacitySales->formatToMinorAmount(), 100), | ||
0 | ||
) : 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.
This is the type of logic that makes me nervous without a unit test 😅
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.
Is such a large refactor required to support Unlimited Capacity? I thought it was just a bug to fix to support 0
as Unlimited? I'm not sure we need to refactor to using null
, which comes with its own set of problems.
While this is stand alone and simple, I think it still should be submitted separately. A separate PR would associate 1:1 with a Jira ticket and could quickly be reviewed, approved, and merged. This is particularly beneficial when the PR to which it is attached is sizable, as it requires the reviewer the separate the context and review multiple changes. |
Call summary (Jon & Paulo)
|
No discussion here? I understand a call can be efficient, but the discussion started here as text. What is wrong with using |
@kjohnson the call summary is where we left the discussion, its not a definitive direction and could use more time dedication that we simply don't have at this moment. |
This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed. |
Resolves GIVE-462 and GIVE-484
Description
Before this pull request, we used to save 0 for the capacity field if left empty. Moving forward, we will store it as null.
This PR includes many changes to support nullable capacity:
ticketsAvailable
prop.ticketsAvailable
before showing the quantity input; otherwise, it displays a simple "Sold Out" label.I have appended the "quantity per ticket in the donation summary" change to this pull request as it is a simple and standalone modification.
Pre-review Checklist
@unreleased
tags included in DocBlocks