diff --git a/server/routes/dashboard.js b/server/routes/dashboard.js index 02534c9..9a9e715 100644 --- a/server/routes/dashboard.js +++ b/server/routes/dashboard.js @@ -21,12 +21,18 @@ router.get('/overview', authenticateToken, async (req, res) => { ] = await Promise.all([ Device.count(), Device.count({ where: { is_active: true } }), - DroneDetection.count(), + DroneDetection.count({ where: { drone_type: { [Op.ne]: 0 } } }), DroneDetection.count({ - where: { server_timestamp: { [Op.gte]: timeWindow } } + where: { + server_timestamp: { [Op.gte]: timeWindow }, + drone_type: { [Op.ne]: 0 } + } }), DroneDetection.count({ - where: { server_timestamp: { [Op.gte]: timeWindow } }, + where: { + server_timestamp: { [Op.gte]: timeWindow }, + drone_type: { [Op.ne]: 0 } + }, distinct: true, col: 'drone_id' }) @@ -106,7 +112,10 @@ router.get('/activity', authenticateToken, async (req, res) => { // Get recent detections with device info const recentDetections = await DroneDetection.findAll({ - where: { server_timestamp: { [Op.gte]: timeWindow } }, + where: { + server_timestamp: { [Op.gte]: timeWindow }, + drone_type: { [Op.ne]: 0 } + }, include: [{ model: Device, as: 'device', @@ -198,7 +207,10 @@ router.get('/charts/detections', authenticateToken, async (req, res) => { } const detectionCounts = await DroneDetection.findAll({ - where: { server_timestamp: { [Op.gte]: timeWindow } }, + where: { + server_timestamp: { [Op.gte]: timeWindow }, + drone_type: { [Op.ne]: 0 } + }, attributes: [ [sequelize.fn('DATE_TRUNC', interval, sequelize.col('server_timestamp')), 'time_bucket'], [sequelize.fn('COUNT', '*'), 'count'] @@ -233,7 +245,10 @@ router.get('/charts/devices', authenticateToken, async (req, res) => { const timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000); const deviceActivity = await DroneDetection.findAll({ - where: { server_timestamp: { [Op.gte]: timeWindow } }, + where: { + server_timestamp: { [Op.gte]: timeWindow }, + drone_type: { [Op.ne]: 0 } + }, attributes: [ 'device_id', [sequelize.fn('COUNT', '*'), 'detection_count'] diff --git a/server/routes/device.js b/server/routes/device.js index bff68bc..6ece4e9 100644 --- a/server/routes/device.js +++ b/server/routes/device.js @@ -77,7 +77,8 @@ router.get('/', authenticateToken, async (req, res) => { device_id: device.id, server_timestamp: { [Op.gte]: new Date(Date.now() - 24 * 60 * 60 * 1000) // Last 24 hours - } + }, + drone_type: { [Op.ne]: 0 } } }); @@ -159,7 +160,8 @@ router.get('/map', authenticateToken, async (req, res) => { device_id: device.id, server_timestamp: { [Op.gte]: new Date(Date.now() - 10 * 60 * 1000) // Last 10 minutes - } + }, + drone_type: { [Op.ne]: 0 } } });