mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-09 23:37:31 -05:00
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
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);
|
|
});
|