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

Bugfix for missing fields in imp.video #1297

Merged
merged 3 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func (deps *endpointDeps) createImpressions(videoReq *openrtb_ext.BidRequestVide

impsArray := make([]openrtb.Imp, numImps)
for impInd := range impsArray {
newImp := createImpressionTemplate(storedImp, videoData)
newImp := createImpressionTemplate(storedImp, *videoData)
impsArray[impInd] = newImp
if reqExactDur {
//floor := int(math.Floor(ind/impDivNumber))
Expand Down Expand Up @@ -380,12 +380,8 @@ func max(a, b int) int {
return b
}

func createImpressionTemplate(imp openrtb.Imp, video *openrtb.Video) openrtb.Imp {
imp.Video = &openrtb.Video{}
imp.Video.W = video.W
imp.Video.H = video.H
imp.Video.Protocols = video.Protocols
imp.Video.MIMEs = video.MIMEs
func createImpressionTemplate(imp openrtb.Imp, video openrtb.Video) openrtb.Imp {
imp.Video = &video
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it would be cleaner to leave the method signature the same as it was before and make the video copy within the method? That might be easier to read / understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored.

return imp
}

Expand Down
25 changes: 25 additions & 0 deletions endpoints/openrtb2/video_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,31 @@ func TestHandleErrorDebugLog(t *testing.T) {
assert.NotEmpty(t, debugLog.CacheKey, "DebugLog CacheKey value should have been set")
}

func TestCreateImpressionTemplate(t *testing.T) {

imp := openrtb.Imp{}
imp.Video = &openrtb.Video{}
imp.Video.Protocols = []openrtb.Protocol{1, 2}
imp.Video.MIMEs = []string{"video/mp4"}
imp.Video.H = 200
imp.Video.W = 400
imp.Video.PlaybackMethod = []openrtb.PlaybackMethod{5, 6}

video := openrtb.Video{}
video.Protocols = []openrtb.Protocol{3, 4}
video.MIMEs = []string{"video/flv"}
video.H = 300
video.W = 0
video.PlaybackMethod = []openrtb.PlaybackMethod{7, 8}

res := createImpressionTemplate(imp, video)
assert.Equal(t, res.Video.Protocols, []openrtb.Protocol{3, 4}, "")
assert.Equal(t, res.Video.MIMEs, []string{"video/flv"}, "")
assert.Equal(t, int(res.Video.H), 300, "")
assert.Equal(t, int(res.Video.W), 0, "")
assert.Equal(t, res.Video.PlaybackMethod, []openrtb.PlaybackMethod{7, 8}, "")
}

func mockDepsWithMetrics(t *testing.T, ex *mockExchangeVideo) (*endpointDeps, *pbsmetrics.Metrics, *mockAnalyticsModule) {
theMetrics := pbsmetrics.NewMetrics(metrics.NewRegistry(), openrtb_ext.BidderList(), config.DisabledMetrics{})
mockModule := &mockAnalyticsModule{}
Expand Down