forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
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
OFF-1457: height should use the compactHeight and standardHeight fields in decisions response #8
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
977baff
add compactHeight and standardHeight fields in decision response
MishelleBit 9060b60
modify tests
MishelleBit 6a0eaf5
modify tests
MishelleBit c9311e8
modify tests
MishelleBit aec0dd6
modify tests
MishelleBit 6e1b7f9
adding height to expectedBidResponses
MishelleBit acbb243
final testing
MishelleBit f3cafbd
final changes
MishelleBit 2eeab0e
final changes
MishelleBit b9647f0
final changes
MishelleBit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,20 @@ import ( | |
) | ||
|
||
const ( | ||
bannerType = "banner" | ||
inlineDivName = "inline" | ||
flippBidder = "flipp" | ||
defaultCurrency = "USD" | ||
bannerType = "banner" | ||
inlineDivName = "inline" | ||
flippBidder = "flipp" | ||
defaultCurrency = "USD" | ||
defaultStandardHeight int64 = 2400 | ||
defaultCompactHeight int64 = 600 | ||
) | ||
|
||
var ( | ||
count int64 = 1 | ||
adTypes = []int64{4309, 641} | ||
dtxTypes = []int64{5061} | ||
count int64 = 1 | ||
adTypes = []int64{4309, 641} | ||
dtxTypes = []int64{5061} | ||
flippExtParams openrtb_ext.ImpExtFlipp | ||
key string | ||
) | ||
|
||
type adapter struct { | ||
|
@@ -198,10 +202,18 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R | |
bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) | ||
bidResponse.Currency = defaultCurrency | ||
for _, imp := range request.Imp { | ||
params, _, _, err := jsonparser.Get(imp.Ext, "bidder") | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("flipp params not found. %v", err)} | ||
} | ||
err = json.Unmarshal(params, &flippExtParams) | ||
if err != nil { | ||
return nil, []error{fmt.Errorf("unable to extract flipp params. %v", err)} | ||
} | ||
for _, decision := range campaignResponseBody.Decisions.Inline { | ||
if *decision.Prebid.RequestID == imp.ID { | ||
b := &adapters.TypedBid{ | ||
Bid: buildBid(decision, imp.ID), | ||
Bid: buildBid(decision, imp.ID, flippExtParams), | ||
BidType: openrtb_ext.BidType(bannerType), | ||
} | ||
bidResponse.Bids = append(bidResponse.Bids, b) | ||
|
@@ -218,7 +230,7 @@ func getAdTypes(creativeType string) []int64 { | |
return adTypes | ||
} | ||
|
||
func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { | ||
func buildBid(decision *InlineModel, impId string, flippExtParams openrtb_ext.ImpExtFlipp) *openrtb2.Bid { | ||
bid := &openrtb2.Bid{ | ||
CrID: fmt.Sprint(decision.CreativeID), | ||
Price: *decision.Prebid.Cpm, | ||
|
@@ -230,7 +242,21 @@ func buildBid(decision *InlineModel, impId string) *openrtb2.Bid { | |
if decision.Contents[0].Data.Width != 0 { | ||
bid.W = decision.Contents[0].Data.Width | ||
} | ||
bid.H = 0 | ||
customDataInterface := decision.Contents[0].Data.CustomData | ||
customDataMap := customDataInterface.(map[string]interface{}) | ||
|
||
if flippExtParams.Options.StartCompact { | ||
bid.H = defaultCompactHeight | ||
key = "compactHeight" | ||
} else { | ||
bid.H = defaultStandardHeight | ||
key = "standardHeight" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then here you can do something like bid.H = defaultStandardHeight
if flippExtParams.Options.StartCompact {
bid.H = defaultCompactHeight
key = "compactHeight"
} |
||
if value, exists := customDataMap[key]; exists { | ||
if floatVal, ok := value.(float64); ok { | ||
bid.H = int64(floatVal) | ||
} | ||
} | ||
} | ||
return bid | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just initialize the key here to be
standardHeight
. Also maybe we can make it a bit more descriptive likecustomDataKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initializing the key there to be standardHeight causes some errors. I think it's because the key will never be modified again in buildBid to standardHeight from compactHeight if it's needed @hasan-kanjee