Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubicon: Update video size-id logic #3917

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 6 additions & 40 deletions adapters/rubicon/rubicon.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prebid/prebid-server/v3/util/maputil"

"github.com/buger/jsonparser"
"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
)

Expand Down Expand Up @@ -174,34 +173,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)
Expand Down Expand Up @@ -374,23 +345,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
Expand Down
46 changes: 0 additions & 46 deletions adapters/rubicon/rubicon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/app-imp-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
3 changes: 2 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/simple-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
},
"bidder": {
"video": {
"size_id": 10
},
"accountId": 1001,
"siteId": 113932,
Expand Down Expand Up @@ -302,7 +303,7 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
"size_id": 10
}
},
"mimes": [
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/site-imp-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
1 change: 0 additions & 1 deletion adapters/rubicon/rubicontest/exemplary/user-fpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
"placement": 3,
"ext": {
"rp": {
"size_id": 203
}
},
"mimes": [
Expand Down

This file was deleted.

Loading