Skip to content

Commit

Permalink
add workaround to prevent IX adapter from ending auction earlier due …
Browse files Browse the repository at this point in the history
…to one request becoming many responses (#763)
  • Loading branch information
Nate Cozi authored and Matt Kendall committed Nov 1, 2016
1 parent 32e1d0f commit 01da63b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/bidmanager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uniques } from './utils';
import { uniques, flatten } from './utils';
import {getPriceBucketString} from './cpmBucketManager';

var CONSTANTS = require('./constants.json');
Expand Down Expand Up @@ -41,8 +41,16 @@ function getBidders(bid) {
}

function bidsBackAdUnit(adUnitCode) {
let requested = $$PREBID_GLOBAL$$.adUnits.find(unit => unit.code === adUnitCode);
if (requested) {requested = requested.bids.length;}
const requested = $$PREBID_GLOBAL$$._bidsRequested
.map(request => request.bids
.filter(bid => bid.placementCode === adUnitCode))
.reduce(flatten)
.map(bid => {
return bid.bidder === 'indexExchange' ?
bid.sizes.length :
1;
}).reduce(add, 0);

const received = $$PREBID_GLOBAL$$._bidsReceived.filter(bid => bid.adUnitCode === adUnitCode).length;
return requested === received;
}
Expand All @@ -52,7 +60,15 @@ function add(a, b) {
}

function bidsBackAll() {
const requested = $$PREBID_GLOBAL$$._bidsRequested.map(bidSet => bidSet.bids.length).reduce(add, 0);
const requested = $$PREBID_GLOBAL$$._bidsRequested
.map(request => request.bids)
.reduce(flatten)
.map(bid => {
return bid.bidder === 'indexExchange' ?
bid.sizes.length :
1;
}).reduce(add, 0);

const received = $$PREBID_GLOBAL$$._bidsReceived.length;
return requested === received;
}
Expand Down

0 comments on commit 01da63b

Please sign in to comment.