-
Notifications
You must be signed in to change notification settings - Fork 228
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!: rights conservation should allow new brands or dropped brands if sum is empty #3036
Conversation
}; | ||
|
||
const assertSumsEqualInMap = (mapToIterate, mapToCheck) => { | ||
mapToIterate.keys().forEach(brand => { |
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.
If you union the brands, you can do each comparison only once.
mapToIterate.keys().forEach(brand => { | |
const allBrands = new Set([...mapToIterate.keys(), ...mapToCheck.keys()]); | |
allBrands.forEach(brand => { |
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.
Oo, nice!
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.
huh, looking at this method in isolation though, we don't know if the brand is defined in the left or the right. And to make empty, we need an amount from the other map. The code gets messy because it doesn't have a place to stand. Let me see if I can improve this.
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.
Ok, pushed up a version that uses allBrands, but is a little more verbose
…f brands as long as the sum is empty
1fd4873
to
940f33d
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.
LGTM
Closes #3033
The rights conservation code previously checked that the brands before and after a proposed allocation were exactly the same. This assumption is wrong, because from a rights allocation perspective, it is ok to include a new brand or drop a brand, as long as the sum is empty.
From the code comments: