changes in get motordata ,added user name

master^2
Varun 11 months ago
parent 92bf80d5c4
commit fb7b4e8751

@ -351,6 +351,7 @@ exports.getTanksofParticularInstaller = async (req, reply) => {
//}; //};
exports.getTankmotordata = async (req, reply) => { exports.getTankmotordata = async (req, reply) => {
try { try {
const { startDate, stopDate } = req.body; 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 // Fetch the name from the User collection based on customerId, only from profile
const user = await User.findOne({ customerId }) const user = await User.findOne({ customerId })
.select("profile.firstName profile.lastName"); .select("username");
if (user) { if (user) {
// Get the full name (combine firstName and lastName if available) // Get the full name (combine firstName and lastName if available)
const userName = user.profile.firstName && user.profile.lastName const userName = user.username
? `${user.profile.firstName} ${user.profile.lastName}` ? `${user.username}`
: "N/A"; // Fallback if no name is found : "N/A"; // Fallback if no name is found
// Construct the query object for motor data based on customerId // Construct the query object for motor data based on customerId

Loading…
Cancel
Save