Skip to content

Commit

Permalink
Replace Id with ID in targeting keys variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
mansinahar committed Jun 6, 2019
1 parent 7245c50 commit 8499c00
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions endpoints/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,13 @@ func sortBidsAddKeywordsMobile(bids pbs.PBSBidSlice, pbs_req *pbs.PBSRequest, pr

hbPbBidderKey := string(openrtb_ext.HbpbConstantKey) + "_" + bid.BidderCode
hbBidderBidderKey := string(openrtb_ext.HbBidderConstantKey) + "_" + bid.BidderCode
hbCacheIDBidderKey := string(openrtb_ext.HbCacheKey) + "_" + bid.BidderCode
hbDealIDBidderKey := string(openrtb_ext.HbDealIdConstantKey) + "_" + bid.BidderCode
HbCacheIDBidderKey := string(openrtb_ext.HbCacheKey) + "_" + bid.BidderCode
hbDealIDBidderKey := string(openrtb_ext.HbDealIDConstantKey) + "_" + bid.BidderCode
hbSizeBidderKey := string(openrtb_ext.HbSizeConstantKey) + "_" + bid.BidderCode
if pbs_req.MaxKeyLength != 0 {
hbPbBidderKey = hbPbBidderKey[:min(len(hbPbBidderKey), int(pbs_req.MaxKeyLength))]
hbBidderBidderKey = hbBidderBidderKey[:min(len(hbBidderBidderKey), int(pbs_req.MaxKeyLength))]
hbCacheIDBidderKey = hbCacheIDBidderKey[:min(len(hbCacheIDBidderKey), int(pbs_req.MaxKeyLength))]
HbCacheIDBidderKey = HbCacheIDBidderKey[:min(len(HbCacheIDBidderKey), int(pbs_req.MaxKeyLength))]
hbDealIDBidderKey = hbDealIDBidderKey[:min(len(hbDealIDBidderKey), int(pbs_req.MaxKeyLength))]
hbSizeBidderKey = hbSizeBidderKey[:min(len(hbSizeBidderKey), int(pbs_req.MaxKeyLength))]
}
Expand All @@ -459,7 +459,7 @@ func sortBidsAddKeywordsMobile(bids pbs.PBSBidSlice, pbs_req *pbs.PBSRequest, pr

kvs[hbPbBidderKey] = roundedCpm
kvs[hbBidderBidderKey] = bid.BidderCode
kvs[hbCacheIDBidderKey] = bid.CacheID
kvs[HbCacheIDBidderKey] = bid.CacheID

if hbSize != "" {
kvs[hbSizeBidderKey] = hbSize
Expand All @@ -473,7 +473,7 @@ func sortBidsAddKeywordsMobile(bids pbs.PBSBidSlice, pbs_req *pbs.PBSRequest, pr
kvs[string(openrtb_ext.HbBidderConstantKey)] = bid.BidderCode
kvs[string(openrtb_ext.HbCacheKey)] = bid.CacheID
if bid.DealId != "" {
kvs[string(openrtb_ext.HbDealIdConstantKey)] = bid.DealId
kvs[string(openrtb_ext.HbDealIDConstantKey)] = bid.DealId
}
if hbSize != "" {
kvs[string(openrtb_ext.HbSizeConstantKey)] = hbSize
Expand Down
12 changes: 6 additions & 6 deletions endpoints/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func TestSortBidsAndAddKeywordsForMobile(t *testing.T) {
if bid.AdServerTargeting[string(openrtb_ext.HbBidderConstantKey)] != "audienceNetwork" {
t.Error(string(openrtb_ext.HbBidderConstantKey) + " key was not parsed correctly")
}
if bid.AdServerTargeting[string(openrtb_ext.HbDealIdConstantKey)] != "2345" {
t.Error(string(openrtb_ext.HbDealIdConstantKey) + " key was not parsed correctly ")
if bid.AdServerTargeting[string(openrtb_ext.HbDealIDConstantKey)] != "2345" {
t.Error(string(openrtb_ext.HbDealIDConstantKey) + " key was not parsed correctly ")
}
}
if bid.BidderCode == "appnexus" {
Expand All @@ -181,8 +181,8 @@ func TestSortBidsAndAddKeywordsForMobile(t *testing.T) {
if bid.AdServerTargeting[string(openrtb_ext.HbpbConstantKey)] != "" {
t.Error(string(openrtb_ext.HbpbConstantKey) + " key was parsed for two bidders")
}
if bid.AdServerTargeting[string(openrtb_ext.HbDealIdConstantKey)+"_appnexus"] != "1234" {
t.Errorf(string(openrtb_ext.HbDealIdConstantKey)+"_appnexus was not parsed correctly %v", bid.AdServerTargeting[string(openrtb_ext.HbDealIdConstantKey)+"_appnexus"])
if bid.AdServerTargeting[string(openrtb_ext.HbDealIDConstantKey)+"_appnexus"] != "1234" {
t.Errorf(string(openrtb_ext.HbDealIDConstantKey)+"_appnexus was not parsed correctly %v", bid.AdServerTargeting[string(openrtb_ext.HbDealIDConstantKey)+"_appnexus"])
}
}
if bid.BidderCode == string(openrtb_ext.BidderRubicon) {
Expand All @@ -196,8 +196,8 @@ func TestSortBidsAndAddKeywordsForMobile(t *testing.T) {
}
}
if bid.BidderCode == "nodeal" {
if _, exists := bid.AdServerTargeting[string(openrtb_ext.HbDealIdConstantKey)+"_nodeal"]; exists {
t.Error(string(openrtb_ext.HbDealIdConstantKey) + " key for nodeal bidder was not parsed correctly")
if _, exists := bid.AdServerTargeting[string(openrtb_ext.HbDealIDConstantKey)+"_nodeal"]; exists {
t.Error(string(openrtb_ext.HbDealIDConstantKey) + " key for nodeal bidder was not parsed correctly")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion endpoints/openrtb2/video_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func buildVideoResponse(bidresponse *openrtb.BidResponse, podErrors []PodError)
videoTargeting := openrtb_ext.VideoTargeting{
HbPb: tempRespBidExt.Prebid.Targeting[string(openrtb_ext.HbpbConstantKey)],
HbPbCatDur: tempRespBidExt.Prebid.Targeting[string(openrtb_ext.HbCategoryDurationKey)],
HbCacheId: tempRespBidExt.Prebid.Targeting[string(openrtb_ext.HbVastCacheKey)],
HbCacheID: tempRespBidExt.Prebid.Targeting[string(openrtb_ext.HbVastCacheKey)],
}

adPod := findAdPod(podId, adPods)
Expand Down
10 changes: 5 additions & 5 deletions exchange/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client,
toCache := make([]prebid_cache_client.Cacheable, 0, expectNumBids+expectNumVast)
expByImp := make(map[string]int64)
competitiveExclusion := false
var hbCacheID string
var HbCacheID string
if len(bidCategory) > 0 {
// assert: category of winning bids never duplicated
if rawUuid, err := uuid.NewV4(); err == nil {
hbCacheID = rawUuid.String()
HbCacheID = rawUuid.String()
competitiveExclusion = true
} else {
errs = append(errs, errors.New("failed to create custom cache key"))
Expand All @@ -102,7 +102,7 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client,
// set custom cache key for winning bid when competitive exclusion applies
catDur = bidCategory[topBidPerBidder.bid.ID]
if len(catDur) > 0 {
customCacheKey = fmt.Sprintf("%s_%s", catDur, hbCacheID)
customCacheKey = fmt.Sprintf("%s_%s", catDur, HbCacheID)
useCustomCacheKey = true
}
}
Expand Down Expand Up @@ -164,9 +164,9 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client,
a.vastCacheIds = make(map[*openrtb.Bid]string, len(vastIndices))
for index, bid := range vastIndices {
if ids[index] != "" {
if competitiveExclusion && strings.HasSuffix(ids[index], hbCacheID) {
if competitiveExclusion && strings.HasSuffix(ids[index], HbCacheID) {
// omit the pb_cat_dur_ portion of cache ID
a.vastCacheIds[bid] = hbCacheID
a.vastCacheIds[bid] = HbCacheID
} else {
a.vastCacheIds[bid] = ids[index]
}
Expand Down
2 changes: 1 addition & 1 deletion exchange/targeting.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (targData *targetData) setTargeting(auc *auction, isApp bool, categoryMappi
targData.addKeys(targets, openrtb_ext.HbVastCacheKey, vastID, bidderName, isOverallWinner)
}
if deal := topBidPerBidder.bid.DealID; len(deal) > 0 {
targData.addKeys(targets, openrtb_ext.HbDealIdConstantKey, deal, bidderName, isOverallWinner)
targData.addKeys(targets, openrtb_ext.HbDealIDConstantKey, deal, bidderName, isOverallWinner)
}

if isApp {
Expand Down
2 changes: 1 addition & 1 deletion openrtb_ext/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const (
// HbBidderConstantKey is the name of the Bidder. For example, "appnexus" or "rubicon".
HbBidderConstantKey TargetingKey = "hb_bidder"
HbSizeConstantKey TargetingKey = "hb_size"
HbDealIdConstantKey TargetingKey = "hb_deal"
HbDealIDConstantKey TargetingKey = "hb_deal"

// HbCacheKey and HbVastCacheKey store UUIDs which can be used to fetch things from prebid cache.
// Callers should *never* assume that either of these exist, since the call to the cache may always fail.
Expand Down
2 changes: 1 addition & 1 deletion openrtb_ext/bid_response_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ type AdPod struct {
type VideoTargeting struct {
HbPb string `json:"hb_pb"`
HbPbCatDur string `json:"hb_pb_cat_dur"`
HbCacheId string `json:"hb_cache_id"`
HbCacheID string `json:"hb_cache_id"`
}

0 comments on commit 8499c00

Please sign in to comment.