v1.1: Add CIDR subnet filtering and Agent filter in Devices page
This commit is contained in:
commit
966058e2fe
422 files changed
+54656
No files matched your search
@@ -0,0 +1,39 @@
|
||||
const express = require('express');
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
async function testSummary() {
|
||||
await mongoose.connect('mongodb://backone_inspect:backone_inspect@mongodb.prod.proit.id:27017/backone_inspect_0');
|
||||
|
||||
const { Summary } = require('./models/Schemas');
|
||||
|
||||
const siteIds = await Summary.distinct('site_uuid', { agent_uuid: null });
|
||||
|
||||
const now = new Date();
|
||||
const delta = 24 * 3600000;
|
||||
const timeFilter = { $gte: new Date(now.getTime() - delta) };
|
||||
|
||||
console.log('Querying with timeFilter:', timeFilter);
|
||||
|
||||
const siteSummaries = await Summary.find({
|
||||
site_uuid: { $in: siteIds },
|
||||
agent_uuid: null,
|
||||
timestamp: timeFilter
|
||||
}).lean();
|
||||
|
||||
let bandwidthDown = 0;
|
||||
let bandwidthUp = 0;
|
||||
|
||||
const validSite = siteSummaries.filter(x => x.bandwidth_down > 0 || x.bandwidth_up > 0);
|
||||
if (validSite.length > 0) {
|
||||
validSite.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));
|
||||
bandwidthDown = validSite[0].bandwidth_down || 0;
|
||||
bandwidthUp = validSite[0].bandwidth_up || 0;
|
||||
}
|
||||
|
||||
console.log('Test validSite length:', validSite.length);
|
||||
console.log('Resulting Bandwidth:', bandwidthDown, bandwidthUp);
|
||||
|
||||
mongoose.disconnect();
|
||||
}
|
||||
|
||||
testSummary();
|
||||
Reference in new issue
Block a user