ashok 3 months ago
commit 5c6522969a

@ -6573,26 +6573,28 @@ exports.getDisconnectedIssuesBySupportId = async (req, reply) => {
.filter(c => c.customerId === customerId) .filter(c => c.customerId === customerId)
.map(c => ({ .map(c => ({
text: c.text, 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") commentsTime: moment(c.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm")
})); }));
for (const master of Object.values(masterMap)) { for (const master of Object.values(masterMap)) {
master.comments = comments; master.comments = comments;
const masterCallRecords = (supportRecord.callRecord || []) // const masterCallRecords = (supportRecord.callRecord || [])
.filter(record => // .filter(record =>
record.customerId === customerId && // record.customerId === customerId &&
record.hardwareId === master.hardwareId // record.hardwareId === master.hardwareId
) // )
.map(record => ({ // .map(record => ({
call_status: record.call_status, // call_status: record.call_status,
call_time: record.call_time, // call_time: record.call_time,
createdAt: record.createdAt // createdAt: record.createdAt
? moment(record.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") // ? moment(record.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm")
: null // : null
})); // }));
master.callRecord = masterCallRecords; // master.callRecord = masterCallRecords;
} }
return reply.send({ return reply.send({
@ -10070,23 +10072,25 @@ if (!orders.length) {
) )
.map(c => ({ .map(c => ({
text: c.text, text: c.text,
call_status: c.call_status,
call_time: c.call_time,
commentsTime: c.createdAt commentsTime: c.createdAt
? moment(c.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") ? moment(c.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm")
: null : null
})); }));
const masterCallRecords = (support.callRecord || []) // const masterCallRecords = (support.callRecord || [])
.filter(call => // .filter(call =>
call.hardwareId === master.hardwareId && // call.hardwareId === master.hardwareId &&
call.customerId === customerId // call.customerId === customerId
) // )
.map(call => ({ // .map(call => ({
call_status: call.call_status, // call_status: call.call_status,
call_time: call.call_time, // call_time: call.call_time,
createdAt: call.createdAt // createdAt: call.createdAt
? moment(call.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm") // ? moment(call.createdAt).tz("Asia/Kolkata").format("DD-MM-YYYY HH:mm")
: null // : null
})); // }));
const trimmedMasterId = (master.hardwareId || "").trim(); const trimmedMasterId = (master.hardwareId || "").trim();
@ -10112,7 +10116,7 @@ if (!orders.length) {
support_gm_last_check_time: master.support_gsm_last_check_time || null, support_gm_last_check_time: master.support_gsm_last_check_time || null,
connected_slaves: slaveDetails, connected_slaves: slaveDetails,
comments: masterComments, comments: masterComments,
callRecord: masterCallRecords, // callRecord: masterCallRecords,
outDoor_status: master.outDoor_status || "inprogress", outDoor_status: master.outDoor_status || "inprogress",
movedAt: category !== "Resolved" ? (issue?.movedAt || null) : null, movedAt: category !== "Resolved" ? (issue?.movedAt || null) : null,
resolvedAt: category === "Resolved" ? (issue?.resolvedAt || null) : null, resolvedAt: category === "Resolved" ? (issue?.resolvedAt || null) : null,
@ -10697,6 +10701,8 @@ exports.updateComments = async (req, reply) => {
// Step 4: Add comment // Step 4: Add comment
const commentObj = { const commentObj = {
text: trimmedComment, text: trimmedComment,
call_status,
call_time,
customerId, customerId,
hardwareId, hardwareId,
createdAt: new Date() createdAt: new Date()
@ -10706,16 +10712,16 @@ exports.updateComments = async (req, reply) => {
supportRecord.comments.push(commentObj); supportRecord.comments.push(commentObj);
// Step 5: Add call record // Step 5: Add call record
const callRecordObj = { // const callRecordObj = {
call_status, // call_status,
call_time, // call_time,
customerId, // customerId,
hardwareId, // hardwareId,
createdAt: new Date() // createdAt: new Date()
}; // };
supportRecord.callRecord = supportRecord.callRecord || []; // supportRecord.callRecord = supportRecord.callRecord || [];
supportRecord.callRecord.push(callRecordObj); // supportRecord.callRecord.push(callRecordObj);
// Save support record // Save support record
await supportRecord.save(); await supportRecord.save();
@ -10725,10 +10731,6 @@ exports.updateComments = async (req, reply) => {
comment: { comment: {
...commentObj, ...commentObj,
createdAt: moment(commentObj.createdAt).format("DD-MM-YYYY HH:mm") createdAt: moment(commentObj.createdAt).format("DD-MM-YYYY HH:mm")
},
callRecord: {
...callRecordObj,
createdAt: moment(callRecordObj.createdAt).format("DD-MM-YYYY HH:mm")
} }
}); });
} catch (error) { } catch (error) {

@ -289,7 +289,9 @@ const installationschema = new mongoose.Schema({
}); });
const CommentSchema = new Schema({ const CommentSchema = new Schema({
text: { type: String, required: true }, text: { type: String },
call_status: { type: String },
call_time: { type: String },
customerId: String, customerId: String,
hardwareId: String, hardwareId: String,
createdAt: { type: Date, default: Date.now } createdAt: { type: Date, default: Date.now }
@ -329,7 +331,7 @@ const installationschema = new mongoose.Schema({
timeOfLogin: { type: String, default: null }, timeOfLogin: { type: String, default: null },
currentTime: { type: Date, default: Date.now }, currentTime: { type: Date, default: Date.now },
comments: [CommentSchema], comments: [CommentSchema],
callRecord: [CallRecordSchema], // callRecord: [CallRecordSchema],
lastTicketRaisedAt: {type : String}, lastTicketRaisedAt: {type : String},
issues: [IssueSchema], issues: [IssueSchema],

Loading…
Cancel
Save