Fix jwt-token

This commit is contained in:
2025-09-09 07:19:58 +02:00
parent 29f7b25954
commit 23e144aec1
2 changed files with 25 additions and 8 deletions

View File

@@ -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']

View File

@@ -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 }
}
});