From a13c57fd686df9e6ec9b5969b6348e41ebfda6c4 Mon Sep 17 00:00:00 2001 From: mkendall07 Date: Fri, 1 Apr 2016 16:17:23 -0400 Subject: [PATCH] Fix for #196 --- src/bidmanager.js | 26 +++++++++++++------------- src/prebid.js | 2 +- test/spec/bidmanager_spec.js | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bidmanager.js b/src/bidmanager.js index fd998e9bb42..f19f355f2a9 100644 --- a/src/bidmanager.js +++ b/src/bidmanager.js @@ -208,20 +208,8 @@ exports.getKeyValueTargetingPairs = function (bidderCode, custBidObj) { var keyValues = {}; var bidder_settings = pbjs.bidderSettings || {}; - //1) set keys from specific bidder setting if they exist - if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { - setKeys(keyValues, bidder_settings[bidderCode], custBidObj); - custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid; - } - - //2) set keys from standard setting. NOTE: this API doesn't seeem to be in use by any Adapter currently - else if (defaultBidderSettingsMap[bidderCode]) { - setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj); - custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid; - } - //3) set the keys from "standard" setting or from prebid defaults - else if (custBidObj && bidder_settings) { + if (custBidObj && bidder_settings) { if (!bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD]) { bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD] = { adserverTargeting: [ @@ -254,6 +242,18 @@ exports.getKeyValueTargetingPairs = function (bidderCode, custBidObj) { setKeys(keyValues, bidder_settings[CONSTANTS.JSON_MAPPING.BD_SETTING_STANDARD], custBidObj); } + //1) set keys from specific bidder setting if they exist + if (bidderCode && custBidObj && bidder_settings && bidder_settings[bidderCode] && bidder_settings[bidderCode][CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { + setKeys(keyValues, bidder_settings[bidderCode], custBidObj); + custBidObj.alwaysUseBid = bidder_settings[bidderCode].alwaysUseBid; + } + + //2) set keys from standard setting. NOTE: this API doesn't seeem to be in use by any Adapter currently + else if (defaultBidderSettingsMap[bidderCode]) { + setKeys(keyValues, defaultBidderSettingsMap[bidderCode], custBidObj); + custBidObj.alwaysUseBid = defaultBidderSettingsMap[bidderCode].alwaysUseBid; + } + return keyValues; }; diff --git a/src/prebid.js b/src/prebid.js index b9b2ff28d9d..8e8fee24d36 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -277,7 +277,7 @@ function buildBidResponse(bidArray) { if (bid.alwaysUseBid && bidClone.adserverTargeting) { // add the bid if alwaysUse and bid has returned // push key into targeting pb_targetingMap[bidClone.adUnitCode] = utils.extend(pb_targetingMap[bidClone.adUnitCode], bidClone.adserverTargeting); - } else if (bid.cpm && bid.cpm > 0) { + } if (bid.cpm && bid.cpm > 0) { //else put into auction array if cpm > 0 bidArrayTargeting.push({ cpm: bid.cpm, diff --git a/test/spec/bidmanager_spec.js b/test/spec/bidmanager_spec.js index 4a503a5f3d6..9e4d058ae6b 100644 --- a/test/spec/bidmanager_spec.js +++ b/test/spec/bidmanager_spec.js @@ -264,7 +264,7 @@ var bidmanager = require('../../src/bidmanager'); } }; - var expected = {"hb_bidder": bidderCode, "hb_adid": adId,"hb_pb": 15.0 }; + var expected = {"hb_bidder": bidderCode, "hb_adid": adId,"hb_pb": 15.0, "hb_size":"300x250" }; var response = bidmanager.getKeyValueTargetingPairs(bidderCode, bid); assert.deepEqual(response, expected);