From 627fde7ee125777e0bee2e4249380d729bda532c Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Thu, 3 Jul 2025 12:15:12 +0530 Subject: [PATCH 1/2] changes on callrecord --- src/controllers/installationController.js | 76 ++++++++++++----------- src/models/store.js | 6 +- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index a159aab8..0d3e6225 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -6579,20 +6579,20 @@ exports.getDisconnectedIssuesBySupportId = async (req, reply) => { for (const master of Object.values(masterMap)) { master.comments = comments; - const masterCallRecords = (supportRecord.callRecord || []) - .filter(record => - record.customerId === customerId && - record.hardwareId === master.hardwareId - ) - .map(record => ({ - call_status: record.call_status, - call_time: record.call_time, - createdAt: record.createdAt - ? moment(record.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") - : null - })); - - master.callRecord = masterCallRecords; + // const masterCallRecords = (supportRecord.callRecord || []) + // .filter(record => + // record.customerId === customerId && + // record.hardwareId === master.hardwareId + // ) + // .map(record => ({ + // call_status: record.call_status, + // call_time: record.call_time, + // createdAt: record.createdAt + // ? moment(record.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") + // : null + // })); + + // master.callRecord = masterCallRecords; } return reply.send({ @@ -10075,18 +10075,18 @@ if (!orders.length) { : null })); - const masterCallRecords = (support.callRecord || []) - .filter(call => - call.hardwareId === master.hardwareId && - call.customerId === customerId - ) - .map(call => ({ - call_status: call.call_status, - call_time: call.call_time, - createdAt: call.createdAt - ? moment(call.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") - : null - })); + // const masterCallRecords = (support.callRecord || []) + // .filter(call => + // call.hardwareId === master.hardwareId && + // call.customerId === customerId + // ) + // .map(call => ({ + // call_status: call.call_status, + // call_time: call.call_time, + // createdAt: call.createdAt + // ? moment(call.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") + // : null + // })); const trimmedMasterId = (master.hardwareId || "").trim(); @@ -10112,7 +10112,7 @@ if (!orders.length) { support_gm_last_check_time: master.support_gsm_last_check_time || null, connected_slaves: slaveDetails, comments: masterComments, - callRecord: masterCallRecords, + // callRecord: masterCallRecords, outDoor_status: master.outDoor_status || "inprogress", movedAt: category !== "Resolved" ? (issue?.movedAt || null) : null, resolvedAt: category === "Resolved" ? (issue?.resolvedAt || null) : null, @@ -10697,6 +10697,8 @@ exports.updateComments = async (req, reply) => { // Step 4: Add comment const commentObj = { text: trimmedComment, + call_status, + call_time, customerId, hardwareId, createdAt: new Date() @@ -10706,16 +10708,16 @@ exports.updateComments = async (req, reply) => { supportRecord.comments.push(commentObj); // Step 5: Add call record - const callRecordObj = { - call_status, - call_time, - customerId, - hardwareId, - createdAt: new Date() - }; - - supportRecord.callRecord = supportRecord.callRecord || []; - supportRecord.callRecord.push(callRecordObj); + // const callRecordObj = { + // call_status, + // call_time, + // customerId, + // hardwareId, + // createdAt: new Date() + // }; + + // supportRecord.callRecord = supportRecord.callRecord || []; + // supportRecord.callRecord.push(callRecordObj); // Save support record await supportRecord.save(); diff --git a/src/models/store.js b/src/models/store.js index a2d184eb..6abacc91 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -289,7 +289,9 @@ const installationschema = new mongoose.Schema({ }); const CommentSchema = new Schema({ - text: { type: String, required: true }, + text: { type: String }, + call_status: { type: String }, + call_time: { type: String }, customerId: String, hardwareId: String, createdAt: { type: Date, default: Date.now } @@ -329,7 +331,7 @@ const installationschema = new mongoose.Schema({ timeOfLogin: { type: String, default: null }, currentTime: { type: Date, default: Date.now }, comments: [CommentSchema], - callRecord: [CallRecordSchema], + // callRecord: [CallRecordSchema], lastTicketRaisedAt: {type : String}, issues: [IssueSchema], From 575492dca02de42cdf5d9a84d88dba981d806435 Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Thu, 3 Jul 2025 12:24:23 +0530 Subject: [PATCH 2/2] changes --- src/controllers/installationController.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 0d3e6225..4fc82a54 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -6573,6 +6573,8 @@ exports.getDisconnectedIssuesBySupportId = async (req, reply) => { .filter(c => c.customerId === customerId) .map(c => ({ text: c.text, + call_status: c.call_status, + call_time: c.call_time, commentsTime: moment(c.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") })); @@ -10070,6 +10072,8 @@ if (!orders.length) { ) .map(c => ({ text: c.text, + call_status: c.call_status, + call_time: c.call_time, commentsTime: c.createdAt ? moment(c.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") : null @@ -10727,10 +10731,6 @@ exports.updateComments = async (req, reply) => { comment: { ...commentObj, createdAt: moment(commentObj.createdAt).format("DD-MM-YYYY HH:mm") - }, - callRecord: { - ...callRecordObj, - createdAt: moment(callRecordObj.createdAt).format("DD-MM-YYYY HH:mm") } }); } catch (error) {