From fb7b4e8751866a9c2b6b34b78dcef3c9baa70375 Mon Sep 17 00:00:00 2001 From: Varun Date: Tue, 28 Jan 2025 15:57:54 +0530 Subject: [PATCH] changes in get motordata ,added user name --- src/controllers/tanksController.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index f8cfd2ea..b09ceb9a 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -351,6 +351,7 @@ exports.getTanksofParticularInstaller = async (req, reply) => { //}; + exports.getTankmotordata = async (req, reply) => { try { const { startDate, stopDate } = req.body; @@ -367,12 +368,12 @@ exports.getTankmotordata = async (req, reply) => { // Fetch the name from the User collection based on customerId, only from profile const user = await User.findOne({ customerId }) - .select("profile.firstName profile.lastName"); + .select("username"); if (user) { // Get the full name (combine firstName and lastName if available) - const userName = user.profile.firstName && user.profile.lastName - ? `${user.profile.firstName} ${user.profile.lastName}` + const userName = user.username + ? `${user.username}` : "N/A"; // Fallback if no name is found // Construct the query object for motor data based on customerId