Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anapaulagomes/53db7ec2f3d31f5c9fb613ca1c737544 to your computer and use it in GitHub Desktop.
Save anapaulagomes/53db7ec2f3d31f5c9fb613ca1c737544 to your computer and use it in GitHub Desktop.
Filtra por finais de semana e agrupa por horas
db.checkins.aggregate([
{'$project':{
'dia_da_semana': {'$dayOfWeek': '$data'},
'usuario.cidades.residencia.pais': 1,
'h':{'$hour':'$data'},
'base.cidade': 1,
'base.nome': 1,
'base.classe': 1
}
},
{ '$match' :
{
'usuario.cidades.residencia.pais': {'$exists': true, '$ne': 'Brazil'},
'dia_da_semana': { '$in': [1,7]},
'base.cidade': 'rio',
'base.nome': 'copa2014',
'base.classe': 'turista'
}
},
{ '$group':{ '_id': { 'hour':'$h'}, 'total':{ '$sum': 1} } },
{'$sort': {'_id.hour': 1}}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment