From dcaa0aa62ddf7f5296b73b1a41b069a64d26a156 Mon Sep 17 00:00:00 2001 From: dhruv-sonone Date: Thu, 20 May 2021 13:25:57 +0530 Subject: [PATCH 1/2] OTT-172: Set Default min Ads value to 1 from 2 --- .../ctv/impressions/impression_generator.go | 2 +- .../impressions/maximize_for_duration_test.go | 25 ++++++++++++++++ .../ctv/impressions/min_max_algorithm_test.go | 29 ++++++++++++++++++- .../ctv/impressions/testdata/input.go | 4 +++ .../ctv/impressions/testdata/output.go | 16 ++++++++++ openrtb_ext/adpod.go | 2 +- 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/endpoints/openrtb2/ctv/impressions/impression_generator.go b/endpoints/openrtb2/ctv/impressions/impression_generator.go index 5488a8dd6a6..4f9edef5886 100644 --- a/endpoints/openrtb2/ctv/impressions/impression_generator.go +++ b/endpoints/openrtb2/ctv/impressions/impression_generator.go @@ -147,7 +147,7 @@ func computeTimeForEachAdSlot(cfg generator, totalAds int64) int64 { // of given number. Prefer to return computed timeForEachSlot // In such case timeForEachSlot no necessarily to be multiples of given number if cfg.requested.slotMinDuration == cfg.requested.slotMaxDuration { - util.Logf("requested.slotMinDuration = requested.slotMinDuration = %v. Hence, not computing multiples of %v value.", cfg.requested.slotMaxDuration, multipleOf) + util.Logf("requested.slotMinDuration = requested.slotMaxDuration = %v. Hence, not computing multiples of %v value.", cfg.requested.slotMaxDuration, multipleOf) return timeForEachSlot } diff --git a/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go b/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go index 2bb7323b0c1..c252573cf68 100644 --- a/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go +++ b/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go @@ -384,6 +384,31 @@ var impressionsTests = []struct { closedMaxDuration: 74, closedSlotMinDuration: 12, closedSlotMaxDuration: 12, + }}, {scenario: "TC56", out: expected{ + impressionCount: 1, + freeTime: 0, closedMinDuration: 126, + closedMaxDuration: 126, + closedSlotMinDuration: 126, + closedSlotMaxDuration: 126, + }}, {scenario: "TC57", out: expected{ + impressionCount: 1, + freeTime: 0, closedMinDuration: 126, + closedMaxDuration: 126, + closedSlotMinDuration: 126, + closedSlotMaxDuration: 126, + }}, {scenario: "TC58", out: expected{ + impressionCount: 4, + freeTime: 0, closedMinDuration: 30, + closedMaxDuration: 90, + closedSlotMinDuration: 15, + closedSlotMaxDuration: 45, + }}, + {scenario: "TC59", out: expected{ + impressionCount: 1, + freeTime: 45, closedMinDuration: 30, + closedMaxDuration: 90, + closedSlotMinDuration: 15, + closedSlotMaxDuration: 45, }}, } diff --git a/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go b/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go index 332e5d78e4c..a1af101626f 100644 --- a/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go +++ b/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go @@ -423,7 +423,34 @@ var impressionsTestsA2 = []struct { step4: [][2]int64{}, step5: [][2]int64{}, }}, - + {scenario: "TC56", out: expectedOutputA2{ + step1: [][2]int64{{126, 126}}, + step2: [][2]int64{{126, 126}}, + step3: [][2]int64{{126, 126}}, + step4: [][2]int64{{126, 126}}, + step5: [][2]int64{{126, 126}}, + }}, + {scenario: "TC57", out: expectedOutputA2{ + step1: [][2]int64{{126, 126}}, + step2: [][2]int64{}, + step3: [][2]int64{{126, 126}}, + step4: [][2]int64{}, + step5: [][2]int64{{126, 126}}, + }}, + {scenario: "TC58", out: expectedOutputA2{ + step1: [][2]int64{{25, 25}, {25, 25}, {20, 20}, {20, 20}}, + step2: [][2]int64{{25, 25}, {25, 25}, {20, 20}, {20, 20}}, + step3: [][2]int64{{45, 45}, {45, 45}}, + step4: [][2]int64{}, + step5: [][2]int64{{15, 15}, {15, 15}}, + }}, + {scenario: "TC59", out: expectedOutputA2{ + step1: [][2]int64{{45, 45}}, + step2: [][2]int64{}, + step3: [][2]int64{}, + step4: [][2]int64{{30, 30}}, + step5: [][2]int64{{30, 30}}, + }}, // {scenario: "TC1" , out: expectedOutputA2{ // step1: [][2]int64{}, // step2: [][2]int64{}, diff --git a/endpoints/openrtb2/ctv/impressions/testdata/input.go b/endpoints/openrtb2/ctv/impressions/testdata/input.go index 8c7ae520f8c..3ee64544b95 100644 --- a/endpoints/openrtb2/ctv/impressions/testdata/input.go +++ b/endpoints/openrtb2/ctv/impressions/testdata/input.go @@ -54,4 +54,8 @@ var Input = map[string][]int{ "TC52": {68, 72, 12, 18, 2, 4}, "TC53": {126, 126, 1, 20, 1, 7}, "TC55": {1, 74, 12, 12, 1, 6}, + "TC56": {126, 126, 126, 126, 1, 1}, + "TC57": {126, 126, 126, 126, 1, 3}, + "TC58": {30, 90, 15, 45, 2, 4}, + "TC59": {30, 90, 15, 45, 1, 1}, } diff --git a/endpoints/openrtb2/ctv/impressions/testdata/output.go b/endpoints/openrtb2/ctv/impressions/testdata/output.go index 7b97c56f2bc..d7e854fc575 100644 --- a/endpoints/openrtb2/ctv/impressions/testdata/output.go +++ b/endpoints/openrtb2/ctv/impressions/testdata/output.go @@ -217,4 +217,20 @@ var Scenario = map[string]eout{ MaximizeForDuration: [][2]int64{{12, 12}, {12, 12}, {12, 12}, {12, 12}, {12, 12}, {12, 12}}, MinMaxAlgorithm: [][2]int64{{12, 12}, {12, 12}, {12, 12}, {12, 12}, {12, 12}, {12, 12}}, }, + "TC56": { + MaximizeForDuration: [][2]int64{{126, 126}}, + MinMaxAlgorithm: [][2]int64{{126, 126}}, + }, + "TC57": { + MaximizeForDuration: [][2]int64{{126, 126}}, + MinMaxAlgorithm: [][2]int64{{126, 126}}, + }, + "TC58": { + MaximizeForDuration: [][2]int64{{25, 25}, {25, 25}, {20, 20}, {20, 20}}, + MinMaxAlgorithm: [][2]int64{{15, 15}, {15, 15}, {15, 20}, {15, 20}, {15, 25}, {15, 25}, {15, 45}, {15, 45}}, + }, + "TC59": { + MaximizeForDuration: [][2]int64{{45, 45}}, + MinMaxAlgorithm: [][2]int64{{30, 30}, {30, 45}}, + }, } diff --git a/openrtb_ext/adpod.go b/openrtb_ext/adpod.go index 03b973b6b5f..ac815cda224 100644 --- a/openrtb_ext/adpod.go +++ b/openrtb_ext/adpod.go @@ -184,7 +184,7 @@ func (ext *ExtVideoAdPod) Validate() (err []error) { func (pod *VideoAdPod) SetDefaultValue() { //pod.MinAds setting default value if nil == pod.MinAds { - pod.MinAds = getIntPtr(2) + pod.MinAds = getIntPtr(1) } //pod.MaxAds setting default value From 04a0bb41dd26aa5925bc6c98afef18dbc1e116d1 Mon Sep 17 00:00:00 2001 From: dhruv-sonone Date: Tue, 25 May 2021 17:02:18 +0530 Subject: [PATCH 2/2] Fixing formating issue --- endpoints/events/vtrack_test.go | 2 +- endpoints/openrtb2/ctv_auction.go | 2 +- exchange/exchange.go | 2 +- exchange/targeting.go | 2 +- router/router.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/endpoints/events/vtrack_test.go b/endpoints/events/vtrack_test.go index 4897fe71034..0f3b5028576 100644 --- a/endpoints/events/vtrack_test.go +++ b/endpoints/events/vtrack_test.go @@ -936,7 +936,7 @@ func TestGetVideoEventTracking(t *testing.T) { name: "valid_scenario", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb2.Bid{ + bid: &openrtb2.Bid{ // AdM: vastXMLWith2Creatives, }, req: &openrtb2.BidRequest{ diff --git a/endpoints/openrtb2/ctv_auction.go b/endpoints/openrtb2/ctv_auction.go index c92ed4d0d17..c8f5a32e307 100644 --- a/endpoints/openrtb2/ctv_auction.go +++ b/endpoints/openrtb2/ctv_auction.go @@ -60,7 +60,7 @@ func NewCTVEndpoint( requestsByID stored_requests.Fetcher, videoFetcher stored_requests.Fetcher, accounts stored_requests.AccountFetcher, -//categories stored_requests.CategoryFetcher, + //categories stored_requests.CategoryFetcher, cfg *config.Configuration, met metrics.MetricsEngine, pbsAnalytics analytics.PBSAnalyticsModule, diff --git a/exchange/exchange.go b/exchange/exchange.go index 9233ea57ec5..41d13e3549e 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -118,7 +118,7 @@ func NewExchange(adapters map[openrtb_ext.BidderName]adaptedBidder, cache prebid LMT: cfg.LMT, }, bidIDGenerator: &bidIDGenerator{cfg.GenerateBidID}, - trakerURL: cfg.TrackerURL, + trakerURL: cfg.TrackerURL, } } diff --git a/exchange/targeting.go b/exchange/targeting.go index c4710f826f0..24c77935bac 100644 --- a/exchange/targeting.go +++ b/exchange/targeting.go @@ -104,4 +104,4 @@ func (targData *targetData) addBidderKeys(keys map[string]string, bidderKeys map keys[index] = element } } -} \ No newline at end of file +} diff --git a/router/router.go b/router/router.go index e79e9782f89..022331effea 100644 --- a/router/router.go +++ b/router/router.go @@ -263,7 +263,7 @@ func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *R if err := validateDefaultAliases(defaultAliases); err != nil { glog.Fatal(err) } - + g_defReqJSON = defReqJSON g_syncers = usersyncers.NewSyncerMap(cfg)