Fix jwt-token
This commit is contained in:
@@ -21,12 +21,18 @@ router.get('/overview', authenticateToken, async (req, res) => {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
Device.count(),
|
Device.count(),
|
||||||
Device.count({ where: { is_active: true } }),
|
Device.count({ where: { is_active: true } }),
|
||||||
DroneDetection.count(),
|
DroneDetection.count({ where: { drone_type: { [Op.ne]: 0 } } }),
|
||||||
DroneDetection.count({
|
DroneDetection.count({
|
||||||
where: { server_timestamp: { [Op.gte]: timeWindow } }
|
where: {
|
||||||
|
server_timestamp: { [Op.gte]: timeWindow },
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
DroneDetection.count({
|
DroneDetection.count({
|
||||||
where: { server_timestamp: { [Op.gte]: timeWindow } },
|
where: {
|
||||||
|
server_timestamp: { [Op.gte]: timeWindow },
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
|
},
|
||||||
distinct: true,
|
distinct: true,
|
||||||
col: 'drone_id'
|
col: 'drone_id'
|
||||||
})
|
})
|
||||||
@@ -106,7 +112,10 @@ router.get('/activity', authenticateToken, async (req, res) => {
|
|||||||
|
|
||||||
// Get recent detections with device info
|
// Get recent detections with device info
|
||||||
const recentDetections = await DroneDetection.findAll({
|
const recentDetections = await DroneDetection.findAll({
|
||||||
where: { server_timestamp: { [Op.gte]: timeWindow } },
|
where: {
|
||||||
|
server_timestamp: { [Op.gte]: timeWindow },
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
|
},
|
||||||
include: [{
|
include: [{
|
||||||
model: Device,
|
model: Device,
|
||||||
as: 'device',
|
as: 'device',
|
||||||
@@ -198,7 +207,10 @@ router.get('/charts/detections', authenticateToken, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const detectionCounts = await DroneDetection.findAll({
|
const detectionCounts = await DroneDetection.findAll({
|
||||||
where: { server_timestamp: { [Op.gte]: timeWindow } },
|
where: {
|
||||||
|
server_timestamp: { [Op.gte]: timeWindow },
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
|
},
|
||||||
attributes: [
|
attributes: [
|
||||||
[sequelize.fn('DATE_TRUNC', interval, sequelize.col('server_timestamp')), 'time_bucket'],
|
[sequelize.fn('DATE_TRUNC', interval, sequelize.col('server_timestamp')), 'time_bucket'],
|
||||||
[sequelize.fn('COUNT', '*'), 'count']
|
[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 timeWindow = new Date(Date.now() - hours * 60 * 60 * 1000);
|
||||||
|
|
||||||
const deviceActivity = await DroneDetection.findAll({
|
const deviceActivity = await DroneDetection.findAll({
|
||||||
where: { server_timestamp: { [Op.gte]: timeWindow } },
|
where: {
|
||||||
|
server_timestamp: { [Op.gte]: timeWindow },
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
|
},
|
||||||
attributes: [
|
attributes: [
|
||||||
'device_id',
|
'device_id',
|
||||||
[sequelize.fn('COUNT', '*'), 'detection_count']
|
[sequelize.fn('COUNT', '*'), 'detection_count']
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ router.get('/', authenticateToken, async (req, res) => {
|
|||||||
device_id: device.id,
|
device_id: device.id,
|
||||||
server_timestamp: {
|
server_timestamp: {
|
||||||
[Op.gte]: new Date(Date.now() - 24 * 60 * 60 * 1000) // Last 24 hours
|
[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,
|
device_id: device.id,
|
||||||
server_timestamp: {
|
server_timestamp: {
|
||||||
[Op.gte]: new Date(Date.now() - 10 * 60 * 1000) // Last 10 minutes
|
[Op.gte]: new Date(Date.now() - 10 * 60 * 1000) // Last 10 minutes
|
||||||
}
|
},
|
||||||
|
drone_type: { [Op.ne]: 0 }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user