Skip to content

Instantly share code, notes, and snippets.

@Rigo85
Last active January 18, 2018 19:53
Show Gist options
  • Save Rigo85/92f05816cafa492b5756068b8f2c2447 to your computer and use it in GitHub Desktop.
Save Rigo85/92f05816cafa492b5756068b8f2c2447 to your computer and use it in GitHub Desktop.
Notification query to MongoDB
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'] }
}
}
])
@Rigo85
Copy link
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