Skip to content

Commit

Permalink
Fix loading of default bid adjustments for "account_defaults" (#3555)
Browse files Browse the repository at this point in the history
* Default account bid adjustments was not loaded

* add a test for account_defaults.bidadjustments

---------

Co-authored-by: oaleksieiev <oleksandr@assertive.ai>
  • Loading branch information
linux019 and oaleksieiev authored Mar 13, 2024
1 parent e78ffb4 commit 4870355
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
30 changes: 30 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,20 @@ account_defaults:
period_sec: 2000
max_age_sec: 6000
max_schema_dims: 10
bidadjustments:
mediatype:
'*':
'*':
'*':
- adjtype: multiplier
value: 1.01
currency: USD
video-instream:
bidder:
deal_id:
- adjtype: cpm
value: 1.02
currency: EUR
privacy:
ipv6:
anon_keep_bits: 50
Expand Down Expand Up @@ -783,7 +797,23 @@ func TestFullConfig(t *testing.T) {
9: &expectedTCF2.Purpose9,
10: &expectedTCF2.Purpose10,
}

expectedBidAdjustments := &openrtb_ext.ExtRequestPrebidBidAdjustments{
MediaType: openrtb_ext.MediaType{
WildCard: map[openrtb_ext.BidderName]openrtb_ext.AdjustmentsByDealID{
"*": {
"*": []openrtb_ext.Adjustment{{Type: "multiplier", Value: 1.01, Currency: "USD"}},
},
},
VideoInstream: map[openrtb_ext.BidderName]openrtb_ext.AdjustmentsByDealID{
"bidder": {
"deal_id": []openrtb_ext.Adjustment{{Type: "cpm", Value: 1.02, Currency: "EUR"}},
},
},
},
}
assert.Equal(t, expectedTCF2, cfg.GDPR.TCF2, "gdpr.tcf2")
assert.Equal(t, expectedBidAdjustments, cfg.AccountDefaults.BidAdjustments)

cmpStrings(t, "currency_converter.fetch_url", "https://currency.prebid.org", cfg.CurrencyConverter.FetchURL)
cmpInts(t, "currency_converter.fetch_interval_seconds", 1800, cfg.CurrencyConverter.FetchIntervalSeconds)
Expand Down
2 changes: 1 addition & 1 deletion exchange/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3177,7 +3177,7 @@ func TestCleanOpenRTBRequestsBidAdjustment(t *testing.T) {
}},
},
{
description: "bidAjustement Not provided",
description: "bidAdjustment Not provided",
gdprAccountEnabled: &falseValue,
gdprHostEnabled: true,
gdpr: "1",
Expand Down
20 changes: 10 additions & 10 deletions openrtb_ext/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ type ExtRequestPrebidCacheVAST struct {

// ExtRequestPrebidBidAdjustments defines the contract for bidrequest.ext.prebid.bidadjustments
type ExtRequestPrebidBidAdjustments struct {
MediaType MediaType `json:"mediatype,omitempty"`
MediaType MediaType `mapstructure:"mediatype" json:"mediatype,omitempty"`
}

// AdjustmentsByDealID maps a dealID to a slice of bid adjustments
Expand All @@ -173,19 +173,19 @@ type AdjustmentsByDealID map[string][]Adjustment
// MediaType defines contract for bidrequest.ext.prebid.bidadjustments.mediatype
// BidderName will map to a DealID that will map to a slice of bid adjustments
type MediaType struct {
Banner map[BidderName]AdjustmentsByDealID `json:"banner,omitempty"`
VideoInstream map[BidderName]AdjustmentsByDealID `json:"video-instream,omitempty"`
VideoOutstream map[BidderName]AdjustmentsByDealID `json:"video-outstream,omitempty"`
Audio map[BidderName]AdjustmentsByDealID `json:"audio,omitempty"`
Native map[BidderName]AdjustmentsByDealID `json:"native,omitempty"`
WildCard map[BidderName]AdjustmentsByDealID `json:"*,omitempty"`
Banner map[BidderName]AdjustmentsByDealID `mapstructure:"banner" json:"banner,omitempty"`
VideoInstream map[BidderName]AdjustmentsByDealID `mapstructure:"video-instream" json:"video-instream,omitempty"`
VideoOutstream map[BidderName]AdjustmentsByDealID `mapstructure:"video-outstream" json:"video-outstream,omitempty"`
Audio map[BidderName]AdjustmentsByDealID `mapstructure:"audio" json:"audio,omitempty"`
Native map[BidderName]AdjustmentsByDealID `mapstructure:"native" json:"native,omitempty"`
WildCard map[BidderName]AdjustmentsByDealID `mapstructure:"*" json:"*,omitempty"`
}

// Adjustment defines the object that will be present in the slice of bid adjustments found from MediaType map
type Adjustment struct {
Type string `json:"adjtype,omitempty"`
Value float64 `json:"value,omitempty"`
Currency string `json:"currency,omitempty"`
Type string `mapstructure:"adjtype" json:"adjtype,omitempty"`
Value float64 `mapstructure:"value" json:"value,omitempty"`
Currency string `mapstructure:"currency" json:"currency,omitempty"`
}

// ExtRequestTargeting defines the contract for bidrequest.ext.prebid.targeting
Expand Down

0 comments on commit 4870355

Please sign in to comment.