Skip to content

Commit da23b18

Browse files
UOE-12687: Support for Tier4 and Tier5 in MBMF
1 parent 3cb8e9f commit da23b18

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

adapters/pubmatic/pubmatic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const MAX_IMPRESSIONS_PUBMATIC = 30
25-
const MAX_MULTIFLOORS_PUBMATIC = 3
25+
const MAX_MULTIFLOORS_PUBMATIC = 5
2626

2727
const (
2828
ae = "ae"

modules/pubmatic/openwrap/database/mysql/mbmf_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestMySqlDBGetProfileAdUnitMultiFloors(t *testing.T) {
4848
wantErr: errors.New("row error"),
4949
},
5050
{
51-
name: "Success case",
51+
name: "Success case with different no. of tiers floors",
5252
fields: fields{
5353
cfg: config.Database{
5454
MaxDbContextTimeout: 5,
@@ -64,7 +64,7 @@ func TestMySqlDBGetProfileAdUnitMultiFloors(t *testing.T) {
6464
}
6565
rows := sqlmock.NewRows([]string{"adunit_name", "profile_id", "value"}).
6666
AddRow("adunit1", 12344, `{"isActive":true,"tier1":1.0,"tier2":0.8,"tier3":0.6}`).
67-
AddRow("adunit2", 54532, `{"isActive":true,"tier1":2.0,"tier2":1.6,"tier3":1.2}`)
67+
AddRow("adunit2", 54532, `{"isActive":true,"tier1":2.0,"tier2":1.6,"tier3":1.2,"tier4":2.4}`)
6868
mock.ExpectQuery("SELECT").WillReturnRows(rows)
6969
return db
7070
},
@@ -73,7 +73,7 @@ func TestMySqlDBGetProfileAdUnitMultiFloors(t *testing.T) {
7373
"adunit1": {IsActive: true, Tier1: 1.0, Tier2: 0.8, Tier3: 0.6},
7474
},
7575
54532: map[string]*models.MultiFloors{
76-
"adunit2": {IsActive: true, Tier1: 2.0, Tier2: 1.6, Tier3: 1.2},
76+
"adunit2": {IsActive: true, Tier1: 2.0, Tier2: 1.6, Tier3: 1.2, Tier4: 2.4},
7777
},
7878
},
7979
wantErr: nil,

modules/pubmatic/openwrap/models/openwrap.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ type MultiFloors struct {
270270
Tier1 float64 `json:"tier1,omitempty"`
271271
Tier2 float64 `json:"tier2,omitempty"`
272272
Tier3 float64 `json:"tier3,omitempty"`
273+
Tier4 float64 `json:"tier4,omitempty"`
274+
Tier5 float64 `json:"tier5,omitempty"`
273275
}
274276

275277
func (w WinningBids) IsWinningBid(impId, bidId string) bool {

modules/pubmatic/openwrap/models/utils.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,13 @@ func GetMultiFloors(multiFloors map[string]*MultiFloors, impID string) []float64
473473
if _, ok := multiFloors[impID]; !ok || multiFloors[impID] == nil {
474474
return nil
475475
}
476-
return []float64{multiFloors[impID].Tier1, multiFloors[impID].Tier2, multiFloors[impID].Tier3}
476+
477+
multifloors := []float64{multiFloors[impID].Tier1, multiFloors[impID].Tier2, multiFloors[impID].Tier3}
478+
if multiFloors[impID].Tier4 > 0 {
479+
multifloors = append(multifloors, multiFloors[impID].Tier4)
480+
}
481+
if multiFloors[impID].Tier5 > 0 {
482+
multifloors = append(multifloors, multiFloors[impID].Tier5)
483+
}
484+
return multifloors
477485
}

modules/pubmatic/openwrap/models/utils_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,16 @@ func TestGetMultiFloors(t *testing.T) {
16431643
impID: "123",
16441644
want: []float64{1.0, 0.8, 0.6},
16451645
},
1646+
{
1647+
name: "impID present with multifloors with tier4 and tier5",
1648+
rctx: &RequestCtx{
1649+
MultiFloors: map[string]*MultiFloors{
1650+
"123": {Tier1: 1.0, Tier2: 0.8, Tier3: 0.6, Tier4: 0.4, Tier5: 0.2},
1651+
},
1652+
},
1653+
impID: "123",
1654+
want: []float64{1.0, 0.8, 0.6, 0.4, 0.2},
1655+
},
16461656
}
16471657
for _, tt := range tests {
16481658
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)