Skip to content

Instantly share code, notes, and snippets.

@maddo
Created July 6, 2012 12:16
Show Gist options
  • Select an option

  • Save maddo/3059832 to your computer and use it in GitHub Desktop.

Select an option

Save maddo/3059832 to your computer and use it in GitHub Desktop.
<?php
$results = $qb
->map($this->getTableReportMapFunction($groupFields))
->reduce('function(k, vals) {
var obj = {
idealDeliveryRate: 0,
delivery: 0,
targetCtr: 0,
targetRate: 0,
impressions: 0,
clicks: 0,
conversions: 0,
ctr: 0,
conversionRate: 0,
revenue: 0,
agencyCommission: 0,
rebate: 0,
cost: 0,
sniperCost: 0,
adServing: 0,
intermediaryMargin: 0,
profitFinal: 0,
profitability: 0,
outdated: 0,
};
for (var i in vals) {
obj.impressions += vals[i].impressions;
obj.clicks += vals[i].clicks;
obj.conversions += vals[i].conversions;
obj.revenue += vals[i].revenue;
obj.agencyCommission += vals[i].agencyCommission;
obj.rebate += vals[i].rebate;
obj.cost += vals[i].cost;
obj.adServing += vals[i].adServing;
obj.intermediaryMargin += vals[i].intermediaryMargin;
obj.idealDeliveryRate += vals[i].idealDeliveryRate;
obj.profitFinal += vals[i].profitFinal;
}
return obj;
}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment