From e49f1260e49e42549fd9a139c363636c2f004a12 Mon Sep 17 00:00:00 2001 From: Bhaskara Kishore Date: Mon, 17 Apr 2023 12:08:54 +0530 Subject: [PATCH 1/2] changes --- src/models/tanks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/tanks.js b/src/models/tanks.js index 8fa2745f..e03f994b 100644 --- a/src/models/tanks.js +++ b/src/models/tanks.js @@ -10,7 +10,7 @@ const ObjectId = Schema.Types.ObjectId; const code = Math.floor(100000 + Math.random() * 900000); const RoleSchema = new Schema({ name: String }); const tanksSchema = new mongoose.Schema({ - hardwareId: { type: String, unique: true, required: true }, + hardwareId: { type: String, unique: true }, customerId: { type: String, default: null }, tankName: { type: String, default: null }, blockName: { type: String, default: null }, @@ -44,7 +44,7 @@ const motordataSchema = new mongoose.Schema({ const IOttankSchema = new mongoose.Schema({ - hardwareId: { type: String, required: true }, + hardwareId: { type: String}, tankHeight: { type: String, required: true }, maxLevel: { type: String, required: true }, minLevel: { type: String, required: true }, From 2a3c55810e78b7175f3821937b3bd165f12e95d6 Mon Sep 17 00:00:00 2001 From: Bhaskara Kishore Date: Mon, 17 Apr 2023 12:28:31 +0530 Subject: [PATCH 2/2] changes --- src/handlers/supplierHandler.js | 45 ++------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/src/handlers/supplierHandler.js b/src/handlers/supplierHandler.js index b91a8670..6eb556fd 100644 --- a/src/handlers/supplierHandler.js +++ b/src/handlers/supplierHandler.js @@ -1019,7 +1019,7 @@ exports.getPendingSuppliers = async (req, reply) => { ); console.log(supplierIdsToInclude, "SUPLIERINCLUDE"); const timestamps = friendRequests.map(request => - moment(request.timestamp).format("DD-MM-YYYY hh:mm:ss") + moment(request.timestamp, "DD-MM-YYYYTHH:mm:ss.SSSZ").format("DD-MM-YYYY hh:mm:ss") ); console.log(timestamps, "timestamps"); await Supplier.find({ supplierId: { $in: supplierIdsToInclude } }) @@ -1079,48 +1079,7 @@ exports.getRejectSuppliers = async (req, reply) => { } }; -// exports.getPendingCustomers = async (req, reply) => { -// const limit = parseInt(req.query.limit) || 100; -// const page = parseInt(req.query.page) || 1; -// const startindex = (page - 1) * limit; -// const supplierId = req.params.supplierId; // Assuming you have already authenticated the user and stored their ID in the request object -// try { -// const friendRequests = await FriendRequest.find({ -// supplierId, -// status: ["pending"], -// }); -// console.log(friendRequests, supplierId, "su...."); -// const supplierIdsToInclude = friendRequests.map( -// (request) => request.customerId -// ); -// console.log(supplierIdsToInclude, "supplierIdsToInclude.."); -// const timestamps = friendRequests.map((request) => request.timestamp); -// console.log(timestamps, "timestamps"); -// await User.find({ customerId: { $in: supplierIdsToInclude } }) -// .limit(limit) -// .skip(startindex) -// .exec() -// .then((docs) => { -// // const customerDataWithTimestamp = docs.map((doc, index) => ({ -// // data: doc, -// // //timestamp: timestamps[index], -// // })); -// reply.send({ status_code: 200, data: docs, count: docs.length }); -// // reply.send({ -// // status_code: 200, -// // data: customerDataWithTimestamp, -// // count: docs.length, -// // }); -// }) -// .catch((err) => { -// console.log(err); -// reply.send({ error: err }); -// }); -// } catch (err) { -// throw boom.boomify(err); -// } -// }; exports.getPendingCustomers = async (req, reply) => { const limit = parseInt(req.query.limit) || 100; @@ -1137,7 +1096,7 @@ exports.getPendingCustomers = async (req, reply) => { (request) => request.customerId ); const timestamps = friendRequests.map(request => - moment(request.timestamp).format("DD-MM-YYYY hh:mm:ss") + moment(request.timestamp, "DD-MM-YYYYTHH:mm:ss.SSSZ").format("DD-MM-YYYY hh:mm:ss") ); await User.find({ customerId: { $in: supplierIdsToInclude } }) .limit(limit)