ashok 3 months ago
commit 5c6522969a

@ -6573,26 +6573,28 @@ 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")
}));
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
}));
// 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;
// master.callRecord = masterCallRecords;
}
return reply.send({
@ -10070,23 +10072,25 @@ 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
}));
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 +10116,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 +10701,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 +10712,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()
};
// const callRecordObj = {
// call_status,
// call_time,
// customerId,
// hardwareId,
// createdAt: new Date()
// };
supportRecord.callRecord = supportRecord.callRecord || [];
supportRecord.callRecord.push(callRecordObj);
// supportRecord.callRecord = supportRecord.callRecord || [];
// supportRecord.callRecord.push(callRecordObj);
// Save support record
await supportRecord.save();
@ -10725,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) {

@ -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],

Loading…
Cancel
Save