-
Notifications
You must be signed in to change notification settings - Fork 753
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
Cache validation fix #911
Cache validation fix #911
Changes from 2 commits
0b83c27
3e84ad8
043be36
6739537
e82b10e
abff28a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,20 +139,30 @@ func (e *exchange) HoldAuction(ctx context.Context, bidRequest *openrtb.BidReque | |
conversions := e.currencyConverter.Rates() | ||
|
||
adapterBids, adapterExtra := e.getAllBids(auctionCtx, cleanRequests, aliases, bidAdjustmentFactors, blabels, conversions) | ||
bidCategory, adapterBids, err := applyCategoryMapping(ctx, requestExt, adapterBids, *categoriesFetcher, targData) | ||
auc := newAuction(adapterBids, len(bidRequest.Imp)) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error in category mapping : %s", err.Error()) | ||
anyBidsReturned := false | ||
for _, seatBid := range adapterBids { | ||
if seatBid != nil && len(seatBid.bids) > 0 { | ||
anyBidsReturned = true | ||
break | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can save a bit of processing time if we remove the
To something like this:
Inside of
To something like:
What do you think? Please let me know if you agree with any of this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's a good idea! Refactored. |
||
if anyBidsReturned { | ||
bidCategory, adapterBids, err := applyCategoryMapping(ctx, requestExt, adapterBids, *categoriesFetcher, targData) | ||
auc := newAuction(adapterBids, len(bidRequest.Imp)) | ||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally makes sense. Done. |
||
return nil, fmt.Errorf("Error in category mapping : %s", err.Error()) | ||
} | ||
|
||
if targData != nil && adapterBids != nil { | ||
auc.setRoundedPrices(targData.priceGranularity) | ||
cacheErrs := auc.doCache(ctx, e.cache, targData, bidRequest, 60, &e.defaultTTLs, bidCategory) | ||
if len(cacheErrs) > 0 { | ||
errs = append(errs, cacheErrs...) | ||
if targData != nil { | ||
auc.setRoundedPrices(targData.priceGranularity) | ||
cacheErrs := auc.doCache(ctx, e.cache, targData, bidRequest, 60, &e.defaultTTLs, bidCategory) | ||
if len(cacheErrs) > 0 { | ||
errs = append(errs, cacheErrs...) | ||
} | ||
targData.setTargeting(auc, bidRequest.App != nil, bidCategory) | ||
} | ||
targData.setTargeting(auc, bidRequest.App != nil, bidCategory) | ||
} | ||
|
||
// Build the response | ||
return e.buildBidResponse(ctx, liveAdapters, adapterBids, bidRequest, resolvedRequest, adapterExtra, errs) | ||
} | ||
|
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.
@Kalypsonika this is very, very minor but, just for the sake of saving memory in the heap and trying to declare as less local variables as possible, can we get rid of lines 406 and 419 and change the return statement in line 421?
What do you think?
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.
Done!