From fc9f9546ac2a0f782c892d48a558f05ce2c0a984 Mon Sep 17 00:00:00 2001 From: Jim Naumann Date: Tue, 8 Jun 2021 23:43:41 -0400 Subject: [PATCH] Beachfront: Fix for bid floor issue#1787 (#1878) Co-authored-by: jim naumann --- adapters/beachfront/beachfront.go | 33 +- .../supplemental/banner-bad-request-400.json | 2 +- .../supplemental/bidfloor-below-min.json | 102 ----- ...-four-variations-on-nothing-adm-video.json | 428 ++++++++++++++++++ .../bidfloor-test-ext-wins-adm-video.json | 124 +++++ .../bidfloor-test-imp-wins-adm-video.json | 125 +++++ adapters/beachfront/params_test.go | 36 +- static/bidder-params/beachfront.json | 21 +- 8 files changed, 747 insertions(+), 124 deletions(-) delete mode 100644 adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json create mode 100644 adapters/beachfront/beachfronttest/supplemental/bidfloor-four-variations-on-nothing-adm-video.json create mode 100644 adapters/beachfront/beachfronttest/supplemental/bidfloor-test-ext-wins-adm-video.json create mode 100644 adapters/beachfront/beachfronttest/supplemental/bidfloor-test-imp-wins-adm-video.json diff --git a/adapters/beachfront/beachfront.go b/adapters/beachfront/beachfront.go index c5f6c4d5b1e..6eba9923e64 100644 --- a/adapters/beachfront/beachfront.go +++ b/adapters/beachfront/beachfront.go @@ -294,14 +294,12 @@ func getBannerRequest(request *openrtb2.BidRequest) (beachfrontBannerRequest, [] continue } + setBidFloor(&beachfrontExt, &request.Imp[i]) + slot := beachfrontSlot{ Id: appid, Slot: request.Imp[i].ID, - Bidfloor: beachfrontExt.BidFloor, - } - - if beachfrontExt.BidFloor <= minBidFloor { - slot.Bidfloor = 0 + Bidfloor: request.Imp[i].BidFloor, } for j := 0; j < len(request.Imp[i].Banner.Format); j++ { @@ -468,12 +466,7 @@ func getVideoRequests(request *openrtb2.BidRequest) ([]beachfrontVideoRequest, [ imp.Banner = nil imp.Ext = nil imp.Secure = &secure - - if beachfrontExt.BidFloor <= minBidFloor { - imp.BidFloor = 0 - } else { - imp.BidFloor = beachfrontExt.BidFloor - } + setBidFloor(&beachfrontExt, &imp) if imp.Video.H == 0 && imp.Video.W == 0 { imp.Video.W = defaultVideoWidth @@ -564,6 +557,24 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb2.BidRequest, exter return bidResponse, errs } +func setBidFloor(ext *openrtb_ext.ExtImpBeachfront, imp *openrtb2.Imp) { + var floor float64 + + if imp.BidFloor > 0 { + floor = imp.BidFloor + } else if ext.BidFloor > 0 { + floor = ext.BidFloor + } else { + floor = minBidFloor + } + + if floor <= minBidFloor { + floor = 0 + } + + imp.BidFloor = floor +} + func (a *BeachfrontAdapter) getBidType(externalRequest *adapters.RequestData) openrtb_ext.BidType { t := strings.Split(externalRequest.Uri, "=")[0] if t == a.extraInfo.VideoEndpoint { diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json b/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json index 426499586f5..7463e2bf374 100644 --- a/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json +++ b/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json @@ -34,7 +34,7 @@ { "slot": "", "id": "dudAppId", - "bidfloor": 5.02, + "bidfloor": 0.02, "sizes": [ { "w": 300, diff --git a/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json b/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json deleted file mode 100644 index 70b89e5db1d..00000000000 --- a/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "mockBidRequest": { - "id": "some_test_ad", - "site": { - "page": "https://some.domain.us/some/page.html" - }, - "imp": [ - { - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } - ] - }, - "ext": { - "bidder": { - "bidfloor": 0.002, - "appId": "bannerAppId1" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://qa.beachrtb.com/prebid_display", - "body": { - "slots": [ - { - "slot": "", - "id": "bannerAppId1", - "bidfloor": 0, - "sizes": [ - { - "w": 300, - "h": 250 - } - ] - } - ], - "domain": "some.domain.us", - "page": "https://some.domain.us/some/page.html", - "real204": true, - "referrer": "", - "search": "", - "secure": 1, - "requestId": "some_test_ad", - "isMobile": 0, - "ip": "", - "deviceModel": "", - "deviceOs": "", - "dnt": 0, - "ua": "", - "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.2", - "user": {}, - "schain": { - "complete": 0, - "nodes": null, - "ver": "" - } - } - }, - "mockResponse": { - "status": 200, - "body": [ - { - "crid": "crid_1", - "price": 2.942808, - "w": 300, - "h": 250, - "slot": "div-gpt-ad-1460505748561-0", - "adm": "