mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 17:27:37 -05:00
First Commit
This commit is contained in:
51
mongo/errors.js
Normal file
51
mongo/errors.js
Normal file
@@ -0,0 +1,51 @@
|
||||
db = db.getMongo().getDB( "scanner" );
|
||||
var start = new Date();
|
||||
start.setHours(start.getHours() - 1);
|
||||
var results = db.calls.aggregate([{
|
||||
$match: {
|
||||
time: {
|
||||
$gte: start
|
||||
},
|
||||
shortName: 'dcfd'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"$unwind": "$freqList"
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"freqList": 1,
|
||||
"errorRatio": {
|
||||
$cond: [{
|
||||
$eq: ["$freqList.len", 0]
|
||||
}, 0, {
|
||||
"$multiply": [{
|
||||
"$divide": ["$freqList.errors", "$freqList.len"]
|
||||
}, 100]
|
||||
}]
|
||||
},
|
||||
"time": "$time"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$group": {
|
||||
"_id": "$freqList.freq",
|
||||
"values": {
|
||||
"$push": {
|
||||
"time": "$time",
|
||||
"errors": "$errorRatio",
|
||||
"spikes": "$freqList.spikes"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
_id: -1
|
||||
}
|
||||
}]);
|
||||
|
||||
results.forEach(function(document) {
|
||||
printjson(document);
|
||||
});
|
||||
Reference in New Issue
Block a user