From 7fc309159e67f9f7c69e18c774a695ffd3b08e19 Mon Sep 17 00:00:00 2001 From: ddubyk Date: Fri, 13 Sep 2024 12:48:19 +0200 Subject: [PATCH] Update video size-id logic. --- adapters/rubicon/rubicon.go | 46 +++---------------- adapters/rubicon/rubicon_test.go | 46 ------------------- .../rubicontest/exemplary/app-imp-fpd.json | 1 - .../exemplary/bidonmultiformat.json | 1 - .../exemplary/flexible-schema.json | 1 - .../exemplary/hardcode-secure.json | 1 - .../rubicontest/exemplary/simple-video.json | 3 +- .../rubicontest/exemplary/site-imp-fpd.json | 1 - .../rubicontest/exemplary/user-fpd.json | 1 - .../supplemental/no-site-content-data.json | 1 - .../supplemental/no-site-content.json | 1 - .../supplemental/required-video-size-id.json | 31 ------------- 12 files changed, 8 insertions(+), 126 deletions(-) delete mode 100644 adapters/rubicon/rubicontest/supplemental/required-video-size-id.json diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 1cb2ab49465..338629d7e29 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -15,7 +15,6 @@ import ( "github.com/prebid/prebid-server/v2/util/maputil" "github.com/buger/jsonparser" - "github.com/prebid/openrtb/v20/adcom1" "github.com/prebid/openrtb/v20/openrtb2" ) @@ -170,34 +169,6 @@ type extPrebid struct { Bidder json.RawMessage `json:"bidder,omitempty"` } -// defines the contract for bidrequest.user.ext.eids[i].ext -type rubiconUserExtEidExt struct { - Segments []string `json:"segments,omitempty"` -} - -type mappedRubiconUidsParam struct { - segments []string - liverampIdl string -} - -func resolveVideoSizeId(placement adcom1.VideoPlacementSubtype, instl int8, impId string) (sizeID int, err error) { - if placement != 0 { - if placement == 1 { - return 201, nil - } - if placement == 3 { - return 203, nil - } - } - - if instl == 1 { - return 202, nil - } - return 0, &errortypes.BadInput{ - Message: fmt.Sprintf("video.size_id can not be resolved in impression with id : %s", impId), - } -} - func appendTrackerToUrl(uri string, tracker string) (res string) { // Append integration method. Adapter init happens once urlObject, err := url.Parse(uri) @@ -369,23 +340,18 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada if isVideo { videoCopy := *imp.Video - videoSizeId := rubiconExt.Video.VideoSizeID - if videoSizeId == 0 { - resolvedSizeId, err := resolveVideoSizeId(imp.Video.Placement, imp.Instl, imp.ID) - if err != nil { - errs = append(errs, err) - continue - } - videoSizeId = resolvedSizeId - } - // if imp.rwdd = 1, set imp.video.ext.videotype = "rewarded" var videoType = "" if imp.Rwdd == 1 { videoType = "rewarded" imp.Rwdd = 0 } - videoExt := rubiconVideoExt{Skip: rubiconExt.Video.Skip, SkipDelay: rubiconExt.Video.SkipDelay, VideoType: videoType, RP: rubiconVideoExtRP{SizeID: videoSizeId}} + videoExt := rubiconVideoExt{ + Skip: rubiconExt.Video.Skip, + SkipDelay: rubiconExt.Video.SkipDelay, + VideoType: videoType, + RP: rubiconVideoExtRP{SizeID: rubiconExt.Video.VideoSizeID}, + } videoCopy.Ext, err = json.Marshal(&videoExt) imp.Video = &videoCopy imp.Banner = nil diff --git a/adapters/rubicon/rubicon_test.go b/adapters/rubicon/rubicon_test.go index 18850d96f9f..ccac135e5b2 100644 --- a/adapters/rubicon/rubicon_test.go +++ b/adapters/rubicon/rubicon_test.go @@ -143,52 +143,6 @@ func TestResolveNativeObject(t *testing.T) { } } -func TestResolveVideoSizeId(t *testing.T) { - testScenarios := []struct { - placement adcom1.VideoPlacementSubtype - instl int8 - impId string - expected int - expectedErr error - }{ - { - placement: 1, - instl: 1, - impId: "impId", - expected: 201, - expectedErr: nil, - }, - { - placement: 3, - instl: 1, - impId: "impId", - expected: 203, - expectedErr: nil, - }, - { - placement: 4, - instl: 1, - impId: "impId", - expected: 202, - expectedErr: nil, - }, - { - placement: 4, - instl: 3, - impId: "impId", - expectedErr: &errortypes.BadInput{ - Message: "video.size_id can not be resolved in impression with id : impId", - }, - }, - } - - for _, scenario := range testScenarios { - res, err := resolveVideoSizeId(scenario.placement, scenario.instl, scenario.impId) - assert.Equal(t, scenario.expected, res) - assert.Equal(t, scenario.expectedErr, err) - } -} - func TestOpenRTBRequestWithDifferentBidFloorAttributes(t *testing.T) { testScenarios := []struct { bidFloor float64 diff --git a/adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json b/adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json index 914cfce03de..37730e15604 100644 --- a/adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json +++ b/adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json @@ -300,7 +300,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json b/adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json index 33757cd889d..22c00a15fd6 100644 --- a/adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json +++ b/adapters/rubicon/rubicontest/exemplary/bidonmultiformat.json @@ -189,7 +189,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/flexible-schema.json b/adapters/rubicon/rubicontest/exemplary/flexible-schema.json index 0434f6bab83..59be8764478 100644 --- a/adapters/rubicon/rubicontest/exemplary/flexible-schema.json +++ b/adapters/rubicon/rubicontest/exemplary/flexible-schema.json @@ -300,7 +300,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/hardcode-secure.json b/adapters/rubicon/rubicontest/exemplary/hardcode-secure.json index c349b86da91..13bff54aacd 100644 --- a/adapters/rubicon/rubicontest/exemplary/hardcode-secure.json +++ b/adapters/rubicon/rubicontest/exemplary/hardcode-secure.json @@ -303,7 +303,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/simple-video.json b/adapters/rubicon/rubicontest/exemplary/simple-video.json index 5552dd71816..ad7c559824e 100644 --- a/adapters/rubicon/rubicontest/exemplary/simple-video.json +++ b/adapters/rubicon/rubicontest/exemplary/simple-video.json @@ -137,6 +137,7 @@ }, "bidder": { "video": { + "size_id": 10 }, "accountId": 1001, "siteId": 113932, @@ -302,7 +303,7 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 + "size_id": 10 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json b/adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json index 87c20e227b1..fb167797428 100644 --- a/adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json +++ b/adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json @@ -415,7 +415,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/exemplary/user-fpd.json b/adapters/rubicon/rubicontest/exemplary/user-fpd.json index 42ab0f0babe..5611318cd82 100644 --- a/adapters/rubicon/rubicontest/exemplary/user-fpd.json +++ b/adapters/rubicon/rubicontest/exemplary/user-fpd.json @@ -244,7 +244,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/supplemental/no-site-content-data.json b/adapters/rubicon/rubicontest/supplemental/no-site-content-data.json index b2f463a95dc..49c50cb0dce 100644 --- a/adapters/rubicon/rubicontest/supplemental/no-site-content-data.json +++ b/adapters/rubicon/rubicontest/supplemental/no-site-content-data.json @@ -215,7 +215,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/supplemental/no-site-content.json b/adapters/rubicon/rubicontest/supplemental/no-site-content.json index 5744b2c9e47..f5dc66e8d5f 100644 --- a/adapters/rubicon/rubicontest/supplemental/no-site-content.json +++ b/adapters/rubicon/rubicontest/supplemental/no-site-content.json @@ -211,7 +211,6 @@ "placement": 3, "ext": { "rp": { - "size_id": 203 } }, "mimes": [ diff --git a/adapters/rubicon/rubicontest/supplemental/required-video-size-id.json b/adapters/rubicon/rubicontest/supplemental/required-video-size-id.json deleted file mode 100644 index 8e7482adfc0..00000000000 --- a/adapters/rubicon/rubicontest/supplemental/required-video-size-id.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-req-id", - "imp": [ - { - "id": "test-imp-1", - "video": { - "w": 640, - "h": 480, - "linearity": 1 - }, - "ext": { - "bidder": { - "accountId": 1001, - "siteId":113932, - "zoneId":535510 - } - } - } - ], - "site": { - "page": "prebid.org" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "video.size_id can not be resolved in impression with id : test-imp-1", - "comparison": "literal" - } - ] -}