mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 08:47:40 -05:00
fixed it!
This commit is contained in:
@@ -13,6 +13,7 @@ exports.get_stats = function(req, res) {
|
||||
var talkgroupStats = sysStats.talkgroupStats(short_name);
|
||||
var uploadErrors = sysStats.uploadErrors(short_name);
|
||||
let decodeErrorsFreq = sysStats.decodeErrorsFreq(short_name);
|
||||
|
||||
if (callTotals && talkgroupStats) {
|
||||
res.contentType('json');
|
||||
res.send(JSON.stringify({
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
let decodeErrorSchema = mongoose.Schema({
|
||||
totalLen: Number,
|
||||
errors: Number,
|
||||
spikes: Number,
|
||||
errorHistory: [Number],
|
||||
spikeHistory: [Number],
|
||||
})
|
||||
|
||||
let talkgroupStatsSchema = mongoose.Schema({
|
||||
calls: Number,
|
||||
totalLen: Number,
|
||||
callCountHistory: [Number],
|
||||
callAvgLenHistory: [Number]
|
||||
})
|
||||
|
||||
@@ -34,26 +34,26 @@ async function updateActiveSystems() {
|
||||
exports.initStats = async function () {
|
||||
// get the System Stats collection
|
||||
|
||||
|
||||
for await (const item of SystemStat.find()) {
|
||||
const obj = item.toObject();
|
||||
// Talkgroup Stats
|
||||
if (item.talkgroupStats != undefined) {
|
||||
talkgroupStats[item.shortName] = obj.talkgroupStats;
|
||||
if (obj.talkgroupStats !== undefined) {
|
||||
talkgroupStats[obj.shortName] = Object.fromEntries(obj.talkgroupStats);
|
||||
}
|
||||
|
||||
// Decode Errors
|
||||
if (item.decodeErrorsFreq != undefined) {
|
||||
decodeErrorsFreq[item.shortName] = obj.decodeErrorsFreq;
|
||||
if (obj.decodeErrorsFreq !== undefined) {
|
||||
|
||||
decodeErrorsFreq[obj.shortName] = Object.fromEntries(obj.decodeErrorsFreq);
|
||||
}
|
||||
|
||||
// Upload Error Totals
|
||||
if (item.uploadErrors != undefined) {
|
||||
uploadErrors[item.shortName] = obj.uploadErrors;
|
||||
if (obj.uploadErrors !== undefined) {
|
||||
uploadErrors[obj.shortName] = obj.uploadErrors;
|
||||
}
|
||||
|
||||
if (item.callTotals != undefined) {
|
||||
callTotals[item.shortName] = obj.callTotals;
|
||||
if (obj.callTotals !== undefined) {
|
||||
callTotals[obj.shortName] = obj.callTotals;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -62,7 +62,7 @@ exports.initStats = async function () {
|
||||
exports.addError = function (call) {
|
||||
|
||||
// if there is no Array associated with the system.
|
||||
if (uploadErrors[call.shortName] == undefined) {
|
||||
if (uploadErrors[call.shortName] === undefined) {
|
||||
uploadErrors[call.shortName] = new Array();
|
||||
for (var j = 0; j < spots; j++) {
|
||||
uploadErrors[call.shortName][j] = 0;
|
||||
@@ -76,12 +76,12 @@ exports.addError = function (call) {
|
||||
// Keeps track of the number of calls for each talkgroup for a system
|
||||
exports.addCall = function (call) {
|
||||
// if you haven't started keeping track of stats for the System yet
|
||||
if (talkgroupStats[call.shortName] == undefined) {
|
||||
if (talkgroupStats[call.shortName] === undefined) {
|
||||
talkgroupStats[call.shortName] = {};
|
||||
}
|
||||
var sysTalkgroupStats = talkgroupStats[call.shortName];
|
||||
// if you haven't started keeping track of Stats for this TG yet...
|
||||
if (sysTalkgroupStats[call.talkgroupNum] == undefined) {
|
||||
if (sysTalkgroupStats[call.talkgroupNum] === undefined) {
|
||||
sysTalkgroupStats[call.talkgroupNum] = {}
|
||||
sysTalkgroupStats[call.talkgroupNum].calls = 0;
|
||||
sysTalkgroupStats[call.talkgroupNum].totalLen = 0;
|
||||
@@ -105,7 +105,7 @@ exports.addCall = function (call) {
|
||||
var sysErrors = decodeErrorsFreq[call.shortName];
|
||||
|
||||
// if you haven't started keeping track of Stats for this TG yet...
|
||||
if (sysErrors[call.freq] == undefined) {
|
||||
if (sysErrors[call.freq] === undefined) {
|
||||
sysErrors[call.freq] = {}
|
||||
sysErrors[call.freq].totalLen = 0;
|
||||
sysErrors[call.freq].errors = 0;
|
||||
|
||||
Reference in New Issue
Block a user