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

Displayio: Make imp.bidfloor optional #3959

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

xdevel
Copy link
Contributor

@xdevel xdevel commented Oct 8, 2024

No description provided.

Copy link

github-actions bot commented Oct 8, 2024

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, fc93365

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:28:	MakeRequests			79.2%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:124:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:167:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:179:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:190:	buildEndpointURL		100.0%
total:									(statements)			85.9%

Comment on lines 44 to 53
if impression.BidFloorCur != "USD" {
convertedValue, err := requestInfo.ConvertCurrency(impression.BidFloor, impression.BidFloorCur, "USD")
if impression.BidFloor != 0 {
convertedValue, err := requestInfo.ConvertCurrency(impression.BidFloor, impression.BidFloorCur, "USD")

if err != nil {
errs = append(errs, err)
continue
if err != nil {
errs = append(errs, err)
continue
}

impression.BidFloor = convertedValue
Copy link
Collaborator

@przemkaczmarek przemkaczmarek Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    convertedValue, err := requestInfo.ConvertCurrency(impression.BidFloor, impression.BidFloorCur, "USD")
    if err != nil {
        errs = append(errs, err)
        continue
    }
    impression.BidFloor = convertedValue
    impression.BidFloorCur = "USD"
} 

Combining the two checks (BidFloor != 0 and BidFloorCur != "USD") into a single if block makes the code more concise and avoids excessive nesting. This improves readability and understanding of the logic because: It expresses in one condition that currency conversion only occurs when the currency is not USD and BidFloor is not zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @przemkaczmarek, thanks for your comment, I'm absolutely agree with your point but the one thing is disturbing me from doing that: https://github.com/prebid/prebid-server/pull/3959/files#diff-8602d2a822defde21ab7f6ced0600ed1c8f36a4faa1278aa67454d388eef17b5R56 . Even if bidfloor is 0 we have to convert (replace in that case) bidfloorcur to USD (as the only supported currency by our server) so I have to use nested if or write another one for this case

Copy link
Collaborator

@przemkaczmarek przemkaczmarek Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xdevel, thanks for pointing that out – I understand now that BidFloorCur needs to be set to "USD" regardless of whether BidFloor is zero or not.

Based on this requirement, here’s the updated code I propose to ensure BidFloorCur is set to "USD" and currency conversion only occurs if BidFloor is greater than zero:

    convertedValue, err := requestInfo.ConvertCurrency(impression.BidFloor, impression.BidFloorCur, "USD")
    if err != nil {
        errs = append(errs, err)
        continue
    }
    impression.BidFloor = convertedValue
    impression.BidFloorCur = "USD"
} else if impression.BidFloorCur != "USD" {
    impression.BidFloorCur = "USD"
}

Its up to You witch solution You choose.

przemkaczmarek
przemkaczmarek previously approved these changes Oct 10, 2024
Copy link

Code coverage summary

Note:

  • Prebid team doesn't anticipate tests covering code paths that might result in marshal and unmarshal errors
  • Coverage summary encompasses all commits leading up to the latest one, 58ada3a

displayio

Refer here for heat map coverage report

github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:28:	MakeRequests			78.8%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:119:	MakeBids			100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:162:	Builder				80.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:174:	getBidMediaTypeFromMtype	100.0%
github.com/prebid/prebid-server/v2/adapters/displayio/displayio.go:185:	buildEndpointURL		100.0%
total:									(statements)			85.7%

@bsardo bsardo changed the title Displayio: make imp.bidfloor optional Displayio: Make imp.bidfloor optional Oct 16, 2024
@bsardo bsardo merged commit 8134328 into prebid:master Oct 16, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants