Skip to content

Commit

Permalink
Fix macro sub, dont do double to string conversions on bid response.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Faul committed Nov 27, 2015
1 parent 65935d8 commit 2951e36
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
Binary file modified Architecture.odp
Binary file not shown.
Binary file modified dump.rdb
Binary file not shown.
Binary file modified libs/xrtb.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/com/xrtb/bidder/Controller.java
Expand Up @@ -387,7 +387,7 @@ public void recordBid(BidResponse br) throws Exception {
Map m = new HashMap();
Pipeline p = bidCache.pipelined();
m.put("ADM",br.getAdmAsString());
m.put("PRICE",""+br.price);
m.put("PRICE",""+br.creat.price);
try {
p.hmset(br.oidStr,m);
p.expire(br.oidStr, Configuration.getInstance().ttl);
Expand Down
10 changes: 10 additions & 0 deletions src/com/xrtb/common/Creative.java
Expand Up @@ -37,6 +37,12 @@ public class Creative {
public Double w;
/** The height of this creative */
public Double h;
/** String representation of w */
transient public String strW;
/** String representation of h */
transient public String strH;
/** String representation of price */
transient public String strPrice;
/** Attributes used with a video */
public List<Node> attributes = new ArrayList<Node>();
/** Input ADM field */
Expand Down Expand Up @@ -90,6 +96,10 @@ void encodeUrl() {
}
encodedAdm = URIEncoder.myUri(s);
}

strW = "" + w;
strH = "" + h;
strPrice = "" + price;
}

/**
Expand Down
15 changes: 7 additions & 8 deletions src/com/xrtb/pojo/BidResponse.java
Expand Up @@ -22,8 +22,6 @@ public class BidResponse {
/** The creative associated with this response */
transient public Creative creat;

/** The response price */
public double price;
/** The response image width */
public double width;
/** The response image height */
Expand Down Expand Up @@ -83,7 +81,6 @@ public BidResponse(BidRequest br, Campaign camp, Creative creat, String oidStr)
imageUrl = creat.imageurl;
adid = camp.adId;
exchange = br.exchange;
price = creat.price;

if (!creat.isNative()) {
width = br.w;
Expand Down Expand Up @@ -142,22 +139,24 @@ public void macroSubs(StringBuilder sb) {

sb = replace(sb,"{campaign_forward_url}", creat.forwardurl);

sb = replace(sb,"{campaign_ad_price}",""+price);
sb = replace(sb,"{campaign_ad_width}",""+creat.w); // TODO replace with a canned string
sb = replace(sb,"{campaign_ad_height}",""+creat.h); // TODO repplace with a canned string
sb = replace(sb,"{campaign_ad_price}",creat.strPrice);
sb = replace(sb,"{campaign_ad_width}",creat.strW); // TODO replace with a canned string
sb = replace(sb,"{campaign_ad_height}",""+creat.strH); // TODO repplace with a canned string
sb = replace(sb,"{creative_id}",creat.impid);
sb = replace(sb,"{campaign_image_url}",creat.imageurl);
sb = replace(sb,"{site_id}",br.siteId);

sb = replaceAll(sb,"{pub}", exchange);
sb = replaceAll(sb,"{bid_id}",oidStr);
sb = replaceAll(sb,"{ad_id}", adid);
sb = replace(sb,"{creative_id}",creat.impid);
sb = replaceAll(sb,"{site_id}",br.siteId);
/* Watch out for encoded stuff */
sb = replaceAll(sb,"%7Bpub%7D", exchange);
sb = replaceAll(sb,"%7Bbid_id%7D",oidStr);
sb = replaceAll(sb,"%7Bad_id%7D",adid);
sb = replaceAll(sb,"%7Bsite_id%7D",br.siteId);
sb = replaceAll(sb,"%7Bcreative_id%7D",creat.impid);
}

/**
Expand Down Expand Up @@ -255,7 +254,7 @@ public void makeResponse() {
snurl.append("/");
snurl.append(br.exchange);
snurl.append("/");
snurl.append(""+ creat.price);
snurl.append(creat.strPrice);
snurl.append("/");
snurl.append(lat);
snurl.append("/");
Expand Down Expand Up @@ -283,7 +282,7 @@ public void makeResponse() {
}

response.append("\",\"price\":");
response.append(price);
response.append(creat.strPrice);
response.append(",\"adid\":\"");
response.append(adid);
response.append("\",\"nurl\":\"");
Expand Down

0 comments on commit 2951e36

Please sign in to comment.