Skip to content
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

Price Floors: Fix bug when caching floor lookup #5673

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/priceFloors.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function getFirstMatchingFloor(floorData, bidObject, responseObject = {})
// if we already have gotten the matching rule from this matching input then use it! No need to look again
let previousMatch = utils.deepAccess(floorData, `matchingInputs.${matchingInput}`);
if (previousMatch) {
return previousMatch;
return {...previousMatch};
msm0504 marked this conversation as resolved.
Show resolved Hide resolved
}
let allPossibleMatches = generatePossibleEnumerations(fieldValues, utils.deepAccess(floorData, 'schema.delimiter') || '|');
let matchingRule = find(allPossibleMatches, hashValue => floorData.values.hasOwnProperty(hashValue));
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/priceFloors_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ describe('the price floors module', function () {
matchingRule: '*'
});
});
it('does not alter cached matched input if conversion occurs', function () {
let inputData = {...basicFloorData};
[0.2, 0.4, 0.6, 0.8].forEach(modifier => {
let result = getFirstMatchingFloor(inputData, basicBidRequest, {mediaType: 'banner', size: '*'});
// result should always be the same
expect(result).to.deep.equal({
matchingFloor: 1.0,
matchingData: 'banner',
matchingRule: 'banner'
});
// make sure a post retrieval adjustment does not alter the cahced floor
robertrmartinez marked this conversation as resolved.
Show resolved Hide resolved
result.matchingFloor = result.matchingFloor * modifier;
});
});
it('selects the right floor for different sizes', function () {
let inputFloorData = {
currency: 'USD',
Expand Down