-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add processing of imp.ext.data to mediagrid #1293
Conversation
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.
Pls add unit tests
|
||
@AllArgsConstructor(staticName = "of") | ||
@Value | ||
public class ExtImp { |
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.
In custom models we prefer to use names like {bidderName}modelName
@@ -21,6 +24,28 @@ protected Imp modifyImp(Imp imp, ExtImpGrid impExt) { | |||
if (impExt.getUid() == null || impExt.getUid() == 0) { | |||
throw new PreBidException("uid is empty"); | |||
} | |||
ExtImp extImp = mapper.mapper().convertValue( |
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.
Can be final
&& extImp.getExtImpData().getAdServer() != null | ||
&& StringUtils.isNotEmpty(extImp.getExtImpData().getAdServer().getAdSlot())) { | ||
|
||
ExtImp modifiedExtImp = ExtImp.of(extImp.getPrebid(), |
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.
Can be final, and also you create model with of
constructor, just to change one value, lets use builder
if (extImp != null | ||
&& extImp.getExtImpData() != null | ||
&& extImp.getExtImpData().getAdServer() != null | ||
&& StringUtils.isNotEmpty(extImp.getExtImpData().getAdServer().getAdSlot())) { |
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.
Lets extract adSlot, and then use if statement
extImp.getExtImpData(), | ||
extImp.getExtImpData().getAdServer().getAdSlot()); | ||
|
||
ObjectNode modifiedExt = mapper.mapper().valueToTree( |
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.
we can move it directly to imp building
imp.toBuilder().ext(mapper.mapper().valueToTree(modifiedExtImp)).build()
GridExtImp.class | ||
); | ||
|
||
String adSlot = getAdSlot(gridExtImp); |
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.
Can be final, but also by saying extracting I mean that we can do something like
final GridExtImp gridExtImp = mapper.mapper().convertValue(imp.getExt(), GridExtImp.class);
final GridExtImpData extImpData = gridExtImp != null ? gridExtImp.getGridExtImpData() : null;
final GridExtImpDataAdServer adServer = extImpData != null ? extImpData.getAdServer() : null;
final String adSlot = adServer != null ? adServer.getAdSlot() : null;
if (StringUtils.isNotEmpty(adSlot)) {
final GridExtImp gridExtImp = mapper.mapper().convertValue( | ||
imp.getExt(), | ||
GridExtImp.class | ||
); |
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.
Can be one line
Imp imp = Imp.builder() | ||
.ext(mapper.valueToTree(gridExtImp)) | ||
.build(); |
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.
Can be one line and also final
This pull request introduces 1 alert when merging 5b5d95d into 5e2b94f - view on LGTM.com new alerts:
|
src/main/java/org/prebid/server/bidder/grid/model/GridExtImp.java
Outdated
Show resolved
Hide resolved
add try/catch clause
This pull request introduces 1 alert when merging 653da6e into 2874e8c - view on LGTM.com new alerts:
|
prebid/prebid-server#1807