-
Notifications
You must be signed in to change notification settings - Fork 32
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
fix: selection of required and not required items #308
Conversation
@@ -74,12 +74,13 @@ public function select() | |||
|
|||
if ($withReplacement === false) { | |||
unset($selectionBag[$baseIndex]); | |||
$selectionBag = array_values($selectionBag); |
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.
Line 95 has the same issue, I believe.
WDYT of reversing the logic here, and populating the $selectionBag
values in a foreach loop, while iterating over $selectableRoutes
, instead of setting all the values there, and then unsetting the unwanted ones?
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 believe Line 95 doesn't have this issue, because the index to access the reindexed array is calculated on each iteration, and not fixed by a foreach
.
I would keep the overall implementation the same, for me it makes sense to pick out the required
items and then randomly pick as much as needed from the leftovers
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.
Oh, yes, true. I wasn't paying enough attention.
Thanks for elaborating!
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.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
- Commits are following conventional commits
- Changelog is updated according to changes (if applicable)
- Documentation is updated according to changes (if applicable)
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.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
Fixed and issue with item/section selection algorithm. Whenever required and non-required are in the route, the selection would go wrong and required item got selected several times.
Related to : https://oat-sa.atlassian.net/browse/TR-3645
How to test
Companion legacy PR :