Created
January 18, 2013 13:29
-
-
Save fforbeck/4564538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function criarCampoEvaluated() { | |
var cursor = db.website_performance.find({evaluated: {$exists: false}}); | |
while (cursor.hasNext()) { | |
var doc = cursor.next(); | |
if (doc) { | |
db.website_performance.update(doc, {$set: {evaluated: false}}); | |
printjson( doc ); | |
} | |
} | |
} | |
function resumirSitesPausadosIndevidamenteBM() { | |
var cursor = db.website_performance.find({impressions: {$gte: 25000}, evaluated: false, leads: {$gt: 0}, revenue: 0}, {cpId:1, adId:1, domain:1}); | |
var dadb = db.getSiblingDB('dadb') | |
while (cursor.hasNext()) { | |
var doc = cursor.next(); | |
if (doc) { | |
var query = {ad_id: doc.adId, domain: doc.domain}; | |
var update = {$set: {weight: 1}}; | |
dadb.rtb_bid_reference_domain.update(query, update); | |
printjson(doc); | |
} | |
} | |
} | |
function resumirSitesPausadosIndevidamenteWN() { | |
var cursor = db.website_performance.find({$and: [{impressions: {$gte: 10000}}, {impressions: {$lt: 25000}}], leads: 0}); | |
var dadb = db.getSiblingDB('dadb') | |
var count = 1; | |
while (cursor.hasNext()) { | |
var doc = cursor.next(); | |
if (doc) { | |
var ctr = (doc.clicks / doc.impressions) * 100; | |
if (ctr > 0.05) { | |
var query = {ad_id: doc.adId, domain: doc.domain}; | |
var update = {$set: {weight: 1}}; | |
dadb.rtb_bid_reference_domain.update(query, update); | |
print('Count ' + count++ + ' | ' + doc.cpId + '-' + doc.adId + ' - ' + doc.domain + ' - CTR: ' + ctr); | |
} | |
} | |
} | |
} | |
function calcularWinRate(campaign) { | |
var cursor = db.website_performance.find({cpId: campaign}); | |
var sumImps = 0; | |
var sumBids = 0; | |
while (cursor.hasNext()) { | |
var doc = cursor.next(); | |
if (doc) { | |
sumImps += doc.impressions; | |
sumBids += doc.bids; | |
} | |
} | |
if (sumImps != 0 && sumBids != 0) { | |
print('Win rate for campaign ' + campaign + ' = ' + sumImps/sumBids); | |
} else { | |
print('Can not calculate win rate for campaign ' + campaign + ' = ' + sumImps + '-' + sumBids); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment