Skip to content

Commit

Permalink
variable rename
Browse files Browse the repository at this point in the history
  • Loading branch information
AvinashKapre committed Nov 25, 2024
1 parent 4b88102 commit cbd3550
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions modules/pubmatic/openwrap/defaultbids.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,38 +186,38 @@ func (m *OpenWrap) addDefaultBidsForMultiFloorsConfig(rctx *models.RequestCtx, b
return defaultBids
}

excludeFloors := make(map[string][]float64, len(bidResponse.SeatBid)) //exclude floors which are already present in bidresponse
var adunitFloors []float64 //floors for each adunit
defaultBidFloors := make(map[string][]float64, len(bidResponse.SeatBid)) //per bidder floors for default bids
bidderExcludeFloors := make(map[string][]float64, len(bidResponse.SeatBid)) //exclude floors which are already present in bidresponse
var adunitFloors []float64 //floors for each adunit
bidderDefaultbidFloors := make(map[string][]float64, len(bidResponse.SeatBid)) //per bidder floors for default bids

// count of pubmatic and pubmatic_alias bids for each impression
seatBidsMultiFloor := make(map[string]map[string]int, len(bidResponse.SeatBid))
// count of pubmatic and pubmatic_alias's bids for each impression
bidderImpBidCounts := make(map[string]map[string]int, len(bidResponse.SeatBid))
for _, seatBid := range bidResponse.SeatBid {
if rctx.PrebidBidderCode[seatBid.Seat] == models.BidderPubMatic || rctx.PrebidBidderCode[seatBid.Seat] == models.BidderPubMaticSecondaryAlias {
for _, bid := range seatBid.Bid {
impId, _ := models.GetImpressionID(bid.ImpID)
var bidExt models.BidExt
if seatBidsMultiFloor[impId] == nil {
seatBidsMultiFloor[impId] = make(map[string]int)
if bidderImpBidCounts[impId] == nil {
bidderImpBidCounts[impId] = make(map[string]int)
}
seatBidsMultiFloor[impId][seatBid.Seat]++
bidderImpBidCounts[impId][seatBid.Seat]++
if bid.Ext != nil {
if err := json.Unmarshal(bid.Ext, &bidExt); err == nil && bidExt.MultiBidMultiFloorValue != 0 {
excludeFloors[seatBid.Seat] = append(excludeFloors[seatBid.Seat], bidExt.MultiBidMultiFloorValue)
bidderExcludeFloors[seatBid.Seat] = append(bidderExcludeFloors[seatBid.Seat], bidExt.MultiBidMultiFloorValue)
}
}
}
}
}

for impID, impCtx := range rctx.ImpBidCtx {
adunitFloors = rctx.AppLovinMax.MultiFloorsConfig.Config[rctx.ImpBidCtx[impID].TagID]
adunitFloors = rctx.AppLovinMax.MultiFloorsConfig.Config[impCtx.TagID]
for bidder := range impCtx.Bidders {
if bidderCode, ok := rctx.PrebidBidderCode[bidder]; ok && (bidderCode != models.BidderPubMatic && bidderCode != models.BidderPubMaticSecondaryAlias) {
if prebidBidderCode, ok := rctx.PrebidBidderCode[bidder]; ok && (prebidBidderCode != models.BidderPubMatic && prebidBidderCode != models.BidderPubMaticSecondaryAlias) {
continue
}
defaultBidsCount := 0
if defaultBidsCount = len(rctx.AppLovinMax.MultiFloorsConfig.Config[impCtx.TagID]) - seatBidsMultiFloor[impID][bidder]; defaultBidsCount <= 0 {
if defaultBidsCount = len(adunitFloors) - bidderImpBidCounts[impID][bidder]; defaultBidsCount <= 0 {
continue
}
if defaultBids[impID] == nil {
Expand All @@ -230,23 +230,23 @@ func (m *OpenWrap) addDefaultBidsForMultiFloorsConfig(rctx *models.RequestCtx, b
}

//exclude floors which are already present in bidresponse for defaultbids
defaultBidFloors[bidder] = make([]float64, 0, defaultBidsCount)
bidderDefaultbidFloors[bidder] = make([]float64, 0, defaultBidsCount)
for _, floor := range adunitFloors {
exclude := false
for _, excludeFloor := range excludeFloors[bidder] {
for _, excludeFloor := range bidderExcludeFloors[bidder] {
if floor == excludeFloor {
exclude = true
break
}
}
if !exclude {
defaultBidFloors[bidder] = append(defaultBidFloors[bidder], floor)
bidderDefaultbidFloors[bidder] = append(bidderDefaultbidFloors[bidder], floor)
}
}

for i := 0; i < defaultBidsCount; i++ {
uuid, _ := m.uuidGenerator.Generate()
bidExt := newDefaultBidExtMultiFloors(defaultBidFloors[bidder][i], bidder, bidResponseExt)
bidExt := newDefaultBidExtMultiFloors(bidderDefaultbidFloors[bidder][i], bidder, bidResponseExt)
bidExtJson, _ := json.Marshal(bidExt)

defaultBids[impID][bidder] = append(defaultBids[impID][bidder], openrtb2.Bid{
Expand Down

0 comments on commit cbd3550

Please sign in to comment.