Skip to content

Instantly share code, notes, and snippets.

@velikanov
Created August 31, 2015 11:49
Show Gist options
  • Save velikanov/0cb2dfa17a32984e0fed to your computer and use it in GitHub Desktop.
Save velikanov/0cb2dfa17a32984e0fed to your computer and use it in GitHub Desktop.
mongo query
db.tracker_lead.aggregate([
{
$group: {
_id: {
year: {
$year: "$created_at"
},
month: {
$month: "$created_at"
},
day: {
$dayOfMonth: "$created_at"
},
flow_id: "$flow.id",
site_id: "$flow.site.id",
offer_kind_id: "$flow.offer_kind.id",
sub1: "$sub1",
sub2: "$sub2",
advertiser_id: "$advertiser_id"
},
click_count: {
$sum: 0
},
conversion_count: {
$sum: 1
},
approved_conversion_count: {
$cond: {
if: {
$eq: ["$status", "confirm"]
},
then: 1,
else: 0
}
}
}
},
{
$limit: 100
}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment