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

Add processing of imp.ext.data to mediagrid #1293

Merged
merged 4 commits into from
Jun 4, 2021
Merged

Add processing of imp.ext.data to mediagrid #1293

merged 4 commits into from
Jun 4, 2021

Conversation

nickluck9
Copy link

@nickluck9 nickluck9 commented Jun 3, 2021

@nickluck9 nickluck9 requested a review from SerhiiNahornyi June 3, 2021 10:16
Copy link
Collaborator

@SerhiiNahornyi SerhiiNahornyi left a 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 {
Copy link
Collaborator

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(
Copy link
Collaborator

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(),
Copy link
Collaborator

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

Comment on lines 32 to 35
if (extImp != null
&& extImp.getExtImpData() != null
&& extImp.getExtImpData().getAdServer() != null
&& StringUtils.isNotEmpty(extImp.getExtImpData().getAdServer().getAdSlot())) {
Copy link
Collaborator

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(
Copy link
Collaborator

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);
Copy link
Collaborator

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)) {

Comment on lines 26 to 29
final GridExtImp gridExtImp = mapper.mapper().convertValue(
imp.getExt(),
GridExtImp.class
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be one line

Comment on lines 244 to 246
Imp imp = Imp.builder()
.ext(mapper.valueToTree(gridExtImp))
.build();
Copy link
Collaborator

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

SerhiiNahornyi
SerhiiNahornyi previously approved these changes Jun 3, 2021
@lgtm-com
Copy link

lgtm-com bot commented Jun 3, 2021

This pull request introduces 1 alert when merging 5b5d95d into 5e2b94f - view on LGTM.com

new alerts:

  • 1 for Dereferenced variable may be null

@rpanchyk rpanchyk changed the title add processing of imp.ext.data to mediagrid Add processing of imp.ext.data to mediagrid Jun 3, 2021
add try/catch clause
@lgtm-com
Copy link

lgtm-com bot commented Jun 4, 2021

This pull request introduces 1 alert when merging 653da6e into 2874e8c - view on LGTM.com

new alerts:

  • 1 for Dereferenced variable may be null

@rpanchyk rpanchyk merged commit ec8a220 into master Jun 4, 2021
@rpanchyk rpanchyk deleted the media_grid branch June 4, 2021 14:14
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.

3 participants