diff --git a/server/routes/detections.js b/server/routes/detections.js index 4511627..396b802 100644 --- a/server/routes/detections.js +++ b/server/routes/detections.js @@ -11,6 +11,9 @@ const router = express.Router(); */ router.get('/', authenticateToken, async (req, res) => { try { + console.log('🔍 DETECTIONS ROUTE HIT - req.url:', req.originalUrl); + console.log('🔍 Query params:', req.query); + const { device_id, drone_id, @@ -44,6 +47,13 @@ router.get('/', authenticateToken, async (req, res) => { // Calculate offset for pagination const offset = (parseInt(page) - 1) * parseInt(limit); + console.log('🔍 About to query with whereClause:', whereClause); + console.log('🔍 Include config:', { + model: 'Device', + as: 'device', + attributes: ['id', 'name', 'geo_lat', 'geo_lon', 'location_description', 'is_approved'] + }); + // Query detections with device information const detections = await DroneDetection.findAll({ where: whereClause, @@ -54,7 +64,8 @@ router.get('/', authenticateToken, async (req, res) => { }], order: [[sort, order.toUpperCase()]], limit: parseInt(limit), - offset: offset + offset: offset, + logging: console.log // Enable SQL logging for this query }); // Get total count for pagination