require('dotenv').config({ path: 'd:/Kuliah/DPI/netify-dashboard/.env.local' }); const mongoose = require('mongoose'); async function testFilter() { await mongoose.connect('mongodb://backone_inspect:backone_inspect@mongodb.prod.proit.id:27017/backone_inspect_0'); console.log("Connected to MongoDB."); // Using the exact collection name mongoose uses for DeviceStat const DeviceStat = mongoose.connection.collection('devicestats'); const kantorUUID = 'F6-2V-DT-8A'; const kantorDevices = await DeviceStat.find({ agent_uuid: kantorUUID }).toArray(); console.log(`\nTotal device records saved in Database specifically for Agent Kantor (${kantorUUID}): ${kantorDevices.length}`); const contaminated = kantorDevices.filter(d => d.ip_address && d.ip_address.startsWith('10.6.')); console.log(`\nOUT OF THOSE, how many have Balaraja IP (10.6.x.x) despite being tagged as Kantor? ${contaminated.length}`); if (contaminated.length > 0) { console.log("Example contaminated IPs in DB under Kantor's UUID:"); console.log(contaminated.slice(0, 5).map(d => `- ${d.ip_address}`).join('\n')); } process.exit(0); } testFilter();