Fix jwt-token
This commit is contained in:
@@ -89,6 +89,19 @@ router.get('/', authenticateToken, async (req, res) => {
|
||||
const expectedInterval = device.heartbeat_interval || 300;
|
||||
const isOnline = timeSinceLastHeartbeat && timeSinceLastHeartbeat < (expectedInterval * 2);
|
||||
|
||||
// Debug logging for device status calculation
|
||||
if (device.id === 1001) { // Stockholm device
|
||||
console.log(`🔍 DEBUG Device ${device.id} status calculation:`);
|
||||
console.log(` Now: ${now.toISOString()}`);
|
||||
console.log(` Last heartbeat: ${device.last_heartbeat}`);
|
||||
console.log(` Time since last: ${timeSinceLastHeartbeat} seconds`);
|
||||
console.log(` Expected interval: ${expectedInterval} seconds`);
|
||||
console.log(` Threshold: ${expectedInterval * 2} seconds`);
|
||||
console.log(` Is online: ${isOnline}`);
|
||||
console.log(` Is active: ${device.is_active}`);
|
||||
console.log(` Final status: ${device.is_active ? (isOnline ? 'online' : 'offline') : 'inactive'}`);
|
||||
}
|
||||
|
||||
return {
|
||||
...device.toJSON(),
|
||||
stats: {
|
||||
|
||||
Reference in New Issue
Block a user