-
Notifications
You must be signed in to change notification settings - Fork 224
Adjust Floors for Bidadjustments #3910
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
Conversation
…justments-for-price-floors # Conflicts: # src/main/java/org/prebid/server/bidadjustments/BidAdjustmentFactorResolver.java # src/main/java/org/prebid/server/bidadjustments/BidAdjustmentsProcessor.java # src/test/java/org/prebid/server/bidadjustments/BidAdjustmentFactorResolverTest.java # src/test/java/org/prebid/server/bidadjustments/BidAdjustmentsProcessorTest.java
…justments-for-price-floors
src/main/java/org/prebid/server/bidadjustments/BidAdjustmentsEnricher.java
Show resolved
Hide resolved
| private Price reversePrice(Price price, | ||
| List<BidAdjustmentsRule> bidAdjustmentRules, | ||
| BidRequest bidRequest) { | ||
|
|
||
| final List<BidAdjustmentsRule> reversedRules = bidAdjustmentRules.reversed(); | ||
| final String resolvedCurrency = price.getCurrency(); | ||
| BigDecimal resolvedPrice = price.getValue(); | ||
|
|
||
| for (BidAdjustmentsRule rule : reversedRules) { | ||
| final BidAdjustmentType adjustmentType = rule.getAdjType(); | ||
| final BigDecimal adjustmentValue = rule.getValue(); | ||
| final String adjustmentCurrency = rule.getCurrency(); | ||
|
|
||
| switch (adjustmentType) { | ||
| case MULTIPLIER -> resolvedPrice = resolvedPrice.divide(adjustmentValue, 4, RoundingMode.HALF_EVEN); | ||
| case CPM -> { | ||
| final BigDecimal convertedAdjustmentValue = currencyService.convertCurrency( | ||
| adjustmentValue, bidRequest, adjustmentCurrency, resolvedCurrency); | ||
| resolvedPrice = BidderUtil.roundFloor(resolvedPrice.add(convertedAdjustmentValue)); | ||
| } | ||
| case STATIC -> throw new PreBidException("STATIC type can't be applied to a floor price"); | ||
| } | ||
| } | ||
|
|
||
| return Price.of(resolvedCurrency, resolvedPrice); | ||
| } |
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.
I think it would be better to extract this method and BidAdjustmentsResolver.adjustPrice into a separate class so that both methods are in the same place. Also, then you can add a test that checks that
reverse(apply(price)) == price
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.
@CTMBNara Not sure I like the idea. The check you suggested is more relevant to the integration/functional tests than unit tests, since this check is about the integrity. Also adjusting and reversing are not the same because of the static adjustment, so the check doesn't hit 100% success rate - it's more likely a use case for the functional test to set it up correctly and check.
src/main/java/org/prebid/server/floors/BasicPriceFloorAdjuster.java
Outdated
Show resolved
Hide resolved
src/test/java/org/prebid/server/bidadjustments/FloorAdjustmentsResolverTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Markiyan Mykush <[email protected]> Co-authored-by: markiian <[email protected]> Co-authored-by: osulzhenko <[email protected]>
…-price-floors # Conflicts: # src/main/java/org/prebid/server/auction/ExchangeService.java
🔧 Type of changes
✨ What's the context?
What's the context for the changes?
🧠 Rationale behind the change
Why did you choose to make these changes? Were there any trade-offs you had to consider?
🔎 New Bid Adapter Checklist
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check