asfdaf
This commit is contained in:
@@ -931,7 +931,9 @@ router.put('/plans/:id/status', validateParams(idParamSchema), async (req, res,
|
|||||||
// @access Private
|
// @access Private
|
||||||
router.get('/logs', async (req, res, next) => {
|
router.get('/logs', async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const { property_id, start_date, end_date, limit = 50 } = req.query;
|
console.log('=== FIRST LOGS ENDPOINT CALLED ===');
|
||||||
|
const { property_id, start_date, end_date, limit = 50, planId } = req.query;
|
||||||
|
console.log('Query params:', { property_id, start_date, end_date, limit, planId });
|
||||||
|
|
||||||
let whereConditions = ['al.user_id = $1'];
|
let whereConditions = ['al.user_id = $1'];
|
||||||
let queryParams = [req.user.id];
|
let queryParams = [req.user.id];
|
||||||
@@ -943,6 +945,12 @@ router.get('/logs', async (req, res, next) => {
|
|||||||
queryParams.push(property_id);
|
queryParams.push(property_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (planId) {
|
||||||
|
paramCount++;
|
||||||
|
whereConditions.push(`al.plan_id = $${paramCount}`);
|
||||||
|
queryParams.push(planId);
|
||||||
|
}
|
||||||
|
|
||||||
if (start_date) {
|
if (start_date) {
|
||||||
paramCount++;
|
paramCount++;
|
||||||
whereConditions.push(`al.application_date >= $${paramCount}`);
|
whereConditions.push(`al.application_date >= $${paramCount}`);
|
||||||
@@ -978,6 +986,19 @@ router.get('/logs', async (req, res, next) => {
|
|||||||
queryParams
|
queryParams
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(`Found ${result.rows.length} logs`);
|
||||||
|
if (result.rows.length > 0) {
|
||||||
|
console.log('First log gps_track:', result.rows[0].gps_track);
|
||||||
|
console.log('First log raw data sample:', {
|
||||||
|
id: result.rows[0].id,
|
||||||
|
plan_id: result.rows[0].plan_id,
|
||||||
|
gps_track: result.rows[0].gps_track,
|
||||||
|
average_speed: result.rows[0].average_speed,
|
||||||
|
area_covered: result.rows[0].area_covered,
|
||||||
|
notes: result.rows[0].notes
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
@@ -986,6 +1007,7 @@ router.get('/logs', async (req, res, next) => {
|
|||||||
planId: log.plan_id,
|
planId: log.plan_id,
|
||||||
applicationDate: log.application_date,
|
applicationDate: log.application_date,
|
||||||
weatherConditions: log.weather_conditions,
|
weatherConditions: log.weather_conditions,
|
||||||
|
gpsTrack: log.gps_track, // ADD THIS MISSING FIELD
|
||||||
averageSpeed: parseFloat(log.average_speed),
|
averageSpeed: parseFloat(log.average_speed),
|
||||||
areaCovered: parseFloat(log.area_covered),
|
areaCovered: parseFloat(log.area_covered),
|
||||||
notes: log.notes,
|
notes: log.notes,
|
||||||
@@ -1411,7 +1433,9 @@ router.post('/logs', validateRequest(applicationLogSchema), async (req, res, nex
|
|||||||
// @access Private
|
// @access Private
|
||||||
router.get('/logs', async (req, res, next) => {
|
router.get('/logs', async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
|
console.log('=== LOGS ENDPOINT CALLED ===');
|
||||||
const { planId } = req.query;
|
const { planId } = req.query;
|
||||||
|
console.log('planId parameter:', planId);
|
||||||
|
|
||||||
let whereConditions = ['p.user_id = $1'];
|
let whereConditions = ['p.user_id = $1'];
|
||||||
let queryParams = [req.user.id];
|
let queryParams = [req.user.id];
|
||||||
|
|||||||
Reference in New Issue
Block a user