Skip to content

Commit

Permalink
update targeting to not include adpod bids (prebid#3558)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored and jaiminpanchal27 committed Feb 27, 2019
1 parent 621a057 commit fcbaa4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/targeting.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp } from './utils';
import { uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp, deepAccess } from './utils';
import { config } from './config';
import { NATIVE_TARGETING_KEYS } from './native';
import { auctionManager } from './auctionManager';
import { sizeSupported } from './sizeMapping';
import { ADPOD } from './mediaTypes';
import includes from 'core-js/library/fn/array/includes';

const utils = require('./utils.js');
Expand Down Expand Up @@ -220,6 +221,7 @@ export function newTargeting(auctionManager) {
}

bidsReceived = bidsReceived
.filter(bid => deepAccess(bid, 'video.context') !== ADPOD)
.filter(bid => bid.mediaType !== 'banner' || sizeSupported([bid.width, bid.height]))
.filter(filters.isUnusedBid)
.filter(filters.isBidNotExpired)
Expand Down
11 changes: 11 additions & 0 deletions test/spec/unit/core/targeting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ describe('targeting tests', function () {
// expect the winning CPM to be equal to the sendAllBidCPM
expect(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_rubicon']).to.deep.equal(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]);
});

it('does not include adpod type bids in the getBidsReceived results', function () {
let adpodBid = utils.deepClone(bid1);
adpodBid.video = { context: 'adpod', durationSeconds: 15, durationBucket: 15 };
adpodBid.cpm = 5;
bidsReceived.push(adpodBid);

const targeting = targetingInstance.getAllTargeting(['/123456/header-bid-tag-0']);
expect(targeting['/123456/header-bid-tag-0']).to.contain.keys('hb_deal', 'hb_adid', 'hb_bidder');
expect(targeting['/123456/header-bid-tag-0']['hb_adid']).to.equal(bid1.adId);
});
}); // end getAllTargeting tests

describe('getAllTargeting without bids return empty object', function () {
Expand Down

0 comments on commit fcbaa4c

Please sign in to comment.