Last active
January 18, 2018 19:53
-
-
Save Rigo85/92f05816cafa492b5756068b8f2c2447 to your computer and use it in GitHub Desktop.
Notification query to MongoDB
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
db.getCollection('apiai_responses').aggregate([ | |
{ | |
$match: | |
{ | |
$and: [ | |
{ 'address.bot.id': '464021083618709' }, | |
{ 'timestamp': { $gte: '2018-01-15T15:00:00', $lte: '2018-01-15T16:00:00' } } | |
] | |
} | |
} | |
, | |
{ | |
$group: { | |
_id: { botid: '$address.bot.id' }, | |
count: { $sum: 1 }, | |
fallback: { $sum: { $cond: [{ $eq: ['Default Fallback Intent', '$result.metadata.intentName'] }, 1, 0] } } | |
} | |
}, | |
{ | |
$project: { | |
count: '$count', | |
fallback: '$fallback', | |
percent: { $divide: ['$fallback', '$count'] } | |
} | |
} | |
]) |
Author
Rigo85
commented
Jan 18, 2018
- the time on the server is 3 hours more than in Chile.
- the notification interval is 1 elapsed hour.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment