Created
May 26, 2016 18:28
-
-
Save anapaulagomes/53db7ec2f3d31f5c9fb613ca1c737544 to your computer and use it in GitHub Desktop.
Filtra por finais de semana e agrupa por horas
This file contains hidden or 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
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