tango-app-api-task 1.0.0-alpha.1 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/controllers/task.controller.js +397 -18
- package/src/controllers/taskActionCenter.controllers.js +229 -113
- package/src/controllers/taskDashboard.controllers.js +65 -23
- package/src/routes/task.routes.js +7 -1
- package/src/routes/taskActionCenter.routes.js +8 -6
- package/src/routes/taskDashboard.routes.js +3 -2
- package/src/service/processedChecklist.service.js +8 -0
- package/src/service/processedTaskList.service.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-task",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"description": "Task",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"handlebars": "^4.7.8",
|
|
24
24
|
"mongodb": "^6.10.0",
|
|
25
25
|
"nodemon": "^3.1.7",
|
|
26
|
-
"tango-api-schema": "^2.1.
|
|
27
|
-
"tango-app-api-middleware": "^3.1.43-alpha.
|
|
26
|
+
"tango-api-schema": "^2.1.94",
|
|
27
|
+
"tango-app-api-middleware": "^3.1.43-alpha.10",
|
|
28
28
|
"winston": "^3.17.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
30
30
|
},
|
|
@@ -6,6 +6,7 @@ import * as taskAssignService from '../service/taskAssign.service.js';
|
|
|
6
6
|
import * as userService from '../service/user.service.js';
|
|
7
7
|
import * as storeService from '../service/store.service.js';
|
|
8
8
|
import * as traxApprover from '../service/approver.service.js';
|
|
9
|
+
import * as processedChecklist from '../service/processedChecklist.service.js';
|
|
9
10
|
// import * as domainService from '../service/domain.service.js';
|
|
10
11
|
import mongoose from 'mongoose';
|
|
11
12
|
const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -16,7 +17,27 @@ dayjs.extend( utc );
|
|
|
16
17
|
dayjs.extend( customParseFormat );
|
|
17
18
|
import * as taskProcessedConfigService from '../service/processedTaskConfig.service.js';
|
|
18
19
|
import * as taskProcessedService from '../service/processedTaskList.service.js';
|
|
19
|
-
|
|
20
|
+
async function LamdaServiceCall( url, data ) {
|
|
21
|
+
try {
|
|
22
|
+
const requestOptions = {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify( data ),
|
|
28
|
+
};
|
|
29
|
+
const response = await fetch( url, requestOptions );
|
|
30
|
+
if ( !response.ok ) {
|
|
31
|
+
throw new Error( `Response status: ${response.status}` );
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const json = await response.json();
|
|
35
|
+
return json;
|
|
36
|
+
} catch ( error ) {
|
|
37
|
+
logger.error( { error: error, message: data, function: 'LamdaServiceCall' } );
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
20
41
|
export async function createUpdateTask( req, res ) {
|
|
21
42
|
try {
|
|
22
43
|
let inputBody = req.body;
|
|
@@ -75,15 +96,19 @@ export async function createUpdateTask( req, res ) {
|
|
|
75
96
|
for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
|
|
76
97
|
let section = inputBody.sections[i];
|
|
77
98
|
section.questions.forEach( ( section ) => {
|
|
78
|
-
if ( section.questionReferenceImage && section.questionReferenceImage
|
|
79
|
-
let
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
if ( section.questionReferenceImage && section.questionReferenceImage.length ) {
|
|
100
|
+
let image = [];
|
|
101
|
+
for ( let img of section.questionReferenceImage ) {
|
|
102
|
+
let imgUrl = decodeURIComponent( img.split( '?' )[0] );
|
|
103
|
+
let url = imgUrl.split( '/' );
|
|
104
|
+
url.splice( 0, 3 );
|
|
105
|
+
image.push( url.join( '/' ) );
|
|
106
|
+
}
|
|
107
|
+
section.questionReferenceImage = image;
|
|
83
108
|
}
|
|
84
109
|
section.answers.forEach( ( answer ) => {
|
|
85
110
|
if ( answer.referenceImage != '' ) {
|
|
86
|
-
let imgUrl = decodeURIComponent( answer.referenceImage
|
|
111
|
+
let imgUrl = decodeURIComponent( answer.referenceImage?.split( '?' )[0] );
|
|
87
112
|
let url = imgUrl.split( '/' );
|
|
88
113
|
url.splice( 0, 3 );
|
|
89
114
|
answer.referenceImage = url.join( '/' );
|
|
@@ -145,6 +170,8 @@ export async function createUpdateTask( req, res ) {
|
|
|
145
170
|
return res.sendSuccess( { checklistId: checkListId, message: message } );
|
|
146
171
|
}
|
|
147
172
|
}
|
|
173
|
+
} else {
|
|
174
|
+
return res.sendError( { message: 'something went wrong' }, 500 );
|
|
148
175
|
}
|
|
149
176
|
} catch ( e ) {
|
|
150
177
|
logger.error( { functionName: 'createTask', error: e } );
|
|
@@ -208,12 +235,24 @@ export async function taskDetails( req, res ) {
|
|
|
208
235
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
209
236
|
questionDetails.forEach( ( item ) => {
|
|
210
237
|
item.question.forEach( async ( question ) => {
|
|
211
|
-
if ( question.questionReferenceImage && question.questionReferenceImage !='' ) {
|
|
238
|
+
if ( question.questionReferenceImage && question.questionReferenceImage !='' && typeof question.questionReferenceImage == 'string' ) {
|
|
212
239
|
let inputData = {
|
|
213
240
|
Bucket: bucket.sop,
|
|
214
241
|
file_path: decodeURIComponent( question.questionReferenceImage ),
|
|
215
242
|
};
|
|
216
243
|
question.questionReferenceImage = await signedUrl( inputData );
|
|
244
|
+
} else {
|
|
245
|
+
if ( question.questionReferenceImage.length ) {
|
|
246
|
+
let image = [];
|
|
247
|
+
for ( let img of question.questionReferenceImage ) {
|
|
248
|
+
let inputData = {
|
|
249
|
+
Bucket: bucket.sop,
|
|
250
|
+
file_path: decodeURIComponent( img ),
|
|
251
|
+
};
|
|
252
|
+
image.push( await signedUrl( inputData ) );
|
|
253
|
+
}
|
|
254
|
+
question.questionReferenceImage = image;
|
|
255
|
+
}
|
|
217
256
|
}
|
|
218
257
|
question.answers.forEach( async ( answer ) => {
|
|
219
258
|
if ( answer.referenceImage != '' ) {
|
|
@@ -297,7 +336,7 @@ export async function validateUser( req, res ) {
|
|
|
297
336
|
}
|
|
298
337
|
if ( alreadyExist.length ) {
|
|
299
338
|
let email = [ ...new Set( alreadyExist ) ];
|
|
300
|
-
return res.sendError( `${email.join()} - email already exist`, 500 );
|
|
339
|
+
return res.sendError( `${email.join()} - email already exist for another brand`, 500 );
|
|
301
340
|
} else {
|
|
302
341
|
userEmail.forEach( ( item ) => {
|
|
303
342
|
data.push( {
|
|
@@ -588,6 +627,7 @@ export async function taskConfig( req, res ) {
|
|
|
588
627
|
let storeCount = 0;
|
|
589
628
|
let locationCount = 0;
|
|
590
629
|
let checklistDetails;
|
|
630
|
+
inputBody.client_id = inputBody.clientId;
|
|
591
631
|
if ( !inputBody._id ) {
|
|
592
632
|
return res.sendError( { message: 'Task Id is Required' }, 400 );
|
|
593
633
|
}
|
|
@@ -605,7 +645,7 @@ export async function taskConfig( req, res ) {
|
|
|
605
645
|
checkListName: inputBody?.checkListName,
|
|
606
646
|
createdBy: req.user._id,
|
|
607
647
|
createdByName: req.user.userName,
|
|
608
|
-
client_id:
|
|
648
|
+
client_id: inputBody.client_id,
|
|
609
649
|
};
|
|
610
650
|
await checklistLogs.create( logInsertData );
|
|
611
651
|
|
|
@@ -617,6 +657,7 @@ export async function taskConfig( req, res ) {
|
|
|
617
657
|
|
|
618
658
|
let configDetails = { ...req.body };
|
|
619
659
|
configDetails.scheduleEndTimeISO = dayjs.utc( configDetails.scheduleEndTime, 'hh:mm A' ).format();
|
|
660
|
+
configDetails.publishDate = dayjs().format();
|
|
620
661
|
|
|
621
662
|
let response = await taskService.updateOne( { _id: inputBody._id }, configDetails );
|
|
622
663
|
if ( inputBody?.approver.length ) {
|
|
@@ -631,7 +672,7 @@ export async function taskConfig( req, res ) {
|
|
|
631
672
|
userEmail: ele.value,
|
|
632
673
|
checkListId: inputBody._id,
|
|
633
674
|
type: 'task',
|
|
634
|
-
client_id:
|
|
675
|
+
client_id: inputBody.client_id,
|
|
635
676
|
} );
|
|
636
677
|
}
|
|
637
678
|
} );
|
|
@@ -653,7 +694,7 @@ export async function taskConfig( req, res ) {
|
|
|
653
694
|
let query = [
|
|
654
695
|
{
|
|
655
696
|
$match: {
|
|
656
|
-
client_id:
|
|
697
|
+
client_id: inputBody.client_id,
|
|
657
698
|
id: { $in: storeList },
|
|
658
699
|
city: { $exists: true },
|
|
659
700
|
},
|
|
@@ -676,7 +717,7 @@ export async function taskConfig( req, res ) {
|
|
|
676
717
|
await taskService.updateOne( { _id: inputBody._id }, { storeCount, locationCount } );
|
|
677
718
|
if ( inputBody.submitType == 'publish' ) {
|
|
678
719
|
let currentDate = dayjs.utc().format();
|
|
679
|
-
let updatedscheduleEndTimeISO = dayjs( checklistDetails?.scheduleDate ).format( 'YYYY-MM-DD' ) + ' ' + checklistDetails.scheduleEndTime;
|
|
720
|
+
let updatedscheduleEndTimeISO = dayjs.utc( checklistDetails?.scheduleDate ).format( 'YYYY-MM-DD' ) + ' ' + checklistDetails.scheduleEndTime;
|
|
680
721
|
updatedscheduleEndTimeISO = dayjs.utc( updatedscheduleEndTimeISO, 'YYYY-MM-DD hh:mm A' ).format();
|
|
681
722
|
if ( updatedscheduleEndTimeISO >= currentDate ) {
|
|
682
723
|
let deleteQuery = {
|
|
@@ -850,6 +891,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
850
891
|
element4.publishDate = getCLconfig.publishDate;
|
|
851
892
|
element4.locationCount = getCLconfig.locationCount;
|
|
852
893
|
element4.scheduleRepeatedType = 'daily';
|
|
894
|
+
element4.approvalEnable = getCLconfig.approver.length ? true : false;
|
|
853
895
|
}
|
|
854
896
|
if ( userIdList.length ) {
|
|
855
897
|
allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
|
|
@@ -993,6 +1035,21 @@ export async function reinitiateTask( req, res ) {
|
|
|
993
1035
|
export async function createChecklistTask( req, res ) {
|
|
994
1036
|
try {
|
|
995
1037
|
let inputBody = req.body;
|
|
1038
|
+
let userId;
|
|
1039
|
+
let userDetails = await userService.findOne( { email: inputBody.userEmail } );
|
|
1040
|
+
if ( !userDetails ) {
|
|
1041
|
+
let userData = {
|
|
1042
|
+
userName: inputBody.userName,
|
|
1043
|
+
email: inputBody.userEmail,
|
|
1044
|
+
mobileNumber: '',
|
|
1045
|
+
clientId: inputBody.clientId,
|
|
1046
|
+
};
|
|
1047
|
+
userId = await createUser( userData );
|
|
1048
|
+
} else {
|
|
1049
|
+
userId = userDetails._id;
|
|
1050
|
+
}
|
|
1051
|
+
let time = inputBody?.scheduleEndTime || '11:59 PM';
|
|
1052
|
+
let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
|
|
996
1053
|
let data = {
|
|
997
1054
|
checkListName: inputBody.checkListName,
|
|
998
1055
|
checkListDescription: inputBody.checkListDescription,
|
|
@@ -1001,15 +1058,15 @@ export async function createChecklistTask( req, res ) {
|
|
|
1001
1058
|
publish: true,
|
|
1002
1059
|
questionCount: 1,
|
|
1003
1060
|
storeCount: 1,
|
|
1004
|
-
scheduleDate:
|
|
1005
|
-
scheduleEndTime:
|
|
1006
|
-
scheduleEndTimeISO: dayjs.utc(
|
|
1061
|
+
scheduleDate: date,
|
|
1062
|
+
scheduleEndTime: time,
|
|
1063
|
+
scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
|
|
1007
1064
|
priorityType: 'high',
|
|
1008
1065
|
client_id: inputBody.clientId,
|
|
1009
1066
|
checkListType: inputBody.checkListType,
|
|
1010
1067
|
publishDate: new Date(),
|
|
1011
1068
|
locationCount: 1,
|
|
1012
|
-
referenceCheckListId: inputBody?.checkListId,
|
|
1069
|
+
referenceCheckListId: inputBody?.checkListId || '',
|
|
1013
1070
|
};
|
|
1014
1071
|
|
|
1015
1072
|
let response = await taskService.create( data );
|
|
@@ -1033,7 +1090,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1033
1090
|
client_id: inputBody.clientId,
|
|
1034
1091
|
};
|
|
1035
1092
|
await taskQuestionService.create( question );
|
|
1036
|
-
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName }, { storeId: 1, storeProfile: 1 } );
|
|
1093
|
+
let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, status: 'active' }, { storeId: 1, storeProfile: 1 } );
|
|
1037
1094
|
if ( !storeDetails ) {
|
|
1038
1095
|
return res.sendError( 'No data found', 204 );
|
|
1039
1096
|
}
|
|
@@ -1047,8 +1104,52 @@ export async function createChecklistTask( req, res ) {
|
|
|
1047
1104
|
checkListId: response?._id,
|
|
1048
1105
|
checkListName: inputBody.checkListName,
|
|
1049
1106
|
client_id: inputBody.clientId,
|
|
1107
|
+
userId: userId,
|
|
1050
1108
|
};
|
|
1051
1109
|
await taskAssignService.create( userDetails );
|
|
1110
|
+
|
|
1111
|
+
if ( inputBody.checkListType == 'checklistTask' ) {
|
|
1112
|
+
let taskDetails = await processedChecklist.findOne( { _id: req.body.processedChecklistId }, { questionAnswers: 1, taskStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1 } );
|
|
1113
|
+
if ( !taskDetails ) {
|
|
1114
|
+
return res.sendError( 'No data found', 204 );
|
|
1115
|
+
}
|
|
1116
|
+
let question = taskDetails.questionAnswers;
|
|
1117
|
+
let sectionIndex = question.findIndex( ( sec ) => sec.section_id == req.body.sectionId );
|
|
1118
|
+
if ( sectionIndex == -1 ) {
|
|
1119
|
+
return res.sendError( 'section is not found', 400 );
|
|
1120
|
+
}
|
|
1121
|
+
let data = { ...question[sectionIndex].questions[req.body.qno - 1], taskId: response?._id, task: true };
|
|
1122
|
+
question[sectionIndex].questions[req.body.qno - 1] = data;
|
|
1123
|
+
taskDetails.questionAnswers = question;
|
|
1124
|
+
let updateData = {
|
|
1125
|
+
taskStatus: true,
|
|
1126
|
+
questionAnswers: question,
|
|
1127
|
+
};
|
|
1128
|
+
await processedChecklist.updateOne( { _id: req.body.processedChecklistId }, updateData );
|
|
1129
|
+
let params = {
|
|
1130
|
+
'payload': {
|
|
1131
|
+
_id: inputBody.processedChecklistId,
|
|
1132
|
+
section_id: inputBody.sectionId,
|
|
1133
|
+
qno: inputBody.qno,
|
|
1134
|
+
},
|
|
1135
|
+
'upsert': {
|
|
1136
|
+
taskId: String( response?._id ),
|
|
1137
|
+
taskStatus: true,
|
|
1138
|
+
task: true,
|
|
1139
|
+
},
|
|
1140
|
+
};
|
|
1141
|
+
const requestOptions = {
|
|
1142
|
+
method: 'POST',
|
|
1143
|
+
headers: {
|
|
1144
|
+
'Content-Type': 'application/json',
|
|
1145
|
+
},
|
|
1146
|
+
body: JSON.stringify( params ),
|
|
1147
|
+
};
|
|
1148
|
+
let searchResponse = await fetch( 'https://7et6pebvmii725tcntww4w56yq0rjpqw.lambda-url.ap-south-1.on.aws/', requestOptions );
|
|
1149
|
+
if ( !searchResponse.ok ) {
|
|
1150
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1052
1153
|
await insertSingleProcessData( response?._id );
|
|
1053
1154
|
return res.sendSuccess( 'Task created successfully' );
|
|
1054
1155
|
}
|
|
@@ -1057,3 +1158,281 @@ export async function createChecklistTask( req, res ) {
|
|
|
1057
1158
|
return res.sendError( e, 500 );
|
|
1058
1159
|
}
|
|
1059
1160
|
}
|
|
1161
|
+
|
|
1162
|
+
export async function approveTask( req, res ) {
|
|
1163
|
+
try {
|
|
1164
|
+
let toDate = new Date( req.body.toDate );
|
|
1165
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
1166
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
1167
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
1168
|
+
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, checklistStatus: 'submit', approvalEnable: true };
|
|
1169
|
+
if ( req.body?.storeId?.length ) {
|
|
1170
|
+
query['store_id'] = { $in: req.body.storeId };
|
|
1171
|
+
}
|
|
1172
|
+
let taskDetails = await taskProcessedService.find( query, { _id: 1 } );
|
|
1173
|
+
if ( !taskDetails.length ) {
|
|
1174
|
+
return res.sendError( 'No data found', 204 );
|
|
1175
|
+
}
|
|
1176
|
+
let idList = taskDetails.map( ( item ) => item._id );
|
|
1177
|
+
let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
|
|
1178
|
+
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
1179
|
+
let params = {
|
|
1180
|
+
'payload': {
|
|
1181
|
+
sourceCheckList_id: req.body.sourceCheckList_id,
|
|
1182
|
+
fromDate: req.body.fromDate,
|
|
1183
|
+
toDate: req.body.toDate,
|
|
1184
|
+
store_id: req.body.storeId,
|
|
1185
|
+
},
|
|
1186
|
+
'upsert': {
|
|
1187
|
+
approvalStatus: true,
|
|
1188
|
+
},
|
|
1189
|
+
};
|
|
1190
|
+
const requestOptions = {
|
|
1191
|
+
method: 'POST',
|
|
1192
|
+
headers: {
|
|
1193
|
+
'Content-Type': 'application/json',
|
|
1194
|
+
},
|
|
1195
|
+
body: JSON.stringify( params ),
|
|
1196
|
+
};
|
|
1197
|
+
let searchResponse = await fetch( 'https://wnx32v5mtyqx6kh3nt6xuosjqa0xvdfq.lambda-url.ap-south-1.on.aws', requestOptions );
|
|
1198
|
+
if ( searchResponse.ok ) {
|
|
1199
|
+
return res.sendSuccess( 'Task Approved successfully' );
|
|
1200
|
+
} else {
|
|
1201
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
} catch ( e ) {
|
|
1205
|
+
logger.error( { function: 'approveTask', error: e } );
|
|
1206
|
+
return res.sendError( e, 500 );
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
export async function redoTask( req, res ) {
|
|
1211
|
+
try {
|
|
1212
|
+
if ( !req.body.payload._id ) {
|
|
1213
|
+
return res.sendError( 'Id is Required', 400 );
|
|
1214
|
+
}
|
|
1215
|
+
if ( !req.body.payload.section_id ) {
|
|
1216
|
+
return res.sendError( 'Section id is Required', 400 );
|
|
1217
|
+
}
|
|
1218
|
+
if ( !req.body.payload.qno ) {
|
|
1219
|
+
return res.sendError( 'Question number is Required', 400 );
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
let taskDetails = await taskProcessedService.findOne( { _id: req.body.payload._id }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1 } );
|
|
1223
|
+
if ( !taskDetails ) {
|
|
1224
|
+
return res.sendError( 'No data found', 204 );
|
|
1225
|
+
}
|
|
1226
|
+
let question = taskDetails.questionAnswers;
|
|
1227
|
+
let sectionIndex = question.findIndex( ( sec ) => sec.section_id == req.body.payload.section_id );
|
|
1228
|
+
if ( sectionIndex == -1 ) {
|
|
1229
|
+
return res.sendError( 'section is not found', 400 );
|
|
1230
|
+
}
|
|
1231
|
+
let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true };
|
|
1232
|
+
let userAnswer = data.userAnswer;
|
|
1233
|
+
question[sectionIndex].questions[req.body.payload.qno - 1] = data;
|
|
1234
|
+
question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
|
|
1235
|
+
taskDetails.questionAnswers = question;
|
|
1236
|
+
let updateData = {
|
|
1237
|
+
checklistStatus: 'open',
|
|
1238
|
+
redoStatus: true,
|
|
1239
|
+
questionAnswers: question,
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
let response = await taskProcessedService.updateOne( { _id: req.body.payload._id }, updateData );
|
|
1243
|
+
if ( response.modifiedCount || response.matchedCount ) {
|
|
1244
|
+
data = {
|
|
1245
|
+
checklistId: taskDetails.sourceCheckList_id,
|
|
1246
|
+
checkListName: taskDetails.checkListName,
|
|
1247
|
+
sectionId: req.body.payload.section_id,
|
|
1248
|
+
sectionName: question[sectionIndex].sectionName,
|
|
1249
|
+
questionName: question[sectionIndex].questions[req.body.payload.qno - 1].qname,
|
|
1250
|
+
action: 'redo',
|
|
1251
|
+
store_id: taskDetails.store_id,
|
|
1252
|
+
storeName: taskDetails.storeName,
|
|
1253
|
+
client_id: taskDetails.client_id,
|
|
1254
|
+
processedChecklistId: taskDetails._id,
|
|
1255
|
+
type: taskDetails.checkListType,
|
|
1256
|
+
userAnswer: userAnswer,
|
|
1257
|
+
};
|
|
1258
|
+
await checklistLogs.create( data );
|
|
1259
|
+
const requestOptions = {
|
|
1260
|
+
method: 'POST',
|
|
1261
|
+
headers: {
|
|
1262
|
+
'Content-Type': 'application/json',
|
|
1263
|
+
},
|
|
1264
|
+
body: JSON.stringify( req.body ),
|
|
1265
|
+
};
|
|
1266
|
+
let searchResponse = await fetch( 'https://ottrgmadjmqptsxdmlckjxdjuy0qvpnt.lambda-url.ap-south-1.on.aws/', requestOptions );
|
|
1267
|
+
if ( searchResponse.ok ) {
|
|
1268
|
+
return res.sendSuccess( 'Question redo successfully' );
|
|
1269
|
+
} else {
|
|
1270
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1271
|
+
}
|
|
1272
|
+
} else {
|
|
1273
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1274
|
+
}
|
|
1275
|
+
} catch ( e ) {
|
|
1276
|
+
logger.error( { function: 'redoChecklist', error: e } );
|
|
1277
|
+
return res.sendError( e, 500 );
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
export async function getQuestions( req, res ) {
|
|
1283
|
+
try {
|
|
1284
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1285
|
+
let resultData = await LamdaServiceCall( url.taskQuestion, req.body );
|
|
1286
|
+
if ( resultData ) {
|
|
1287
|
+
if ( resultData.status_code == '200' ) {
|
|
1288
|
+
return res.sendSuccess( resultData );
|
|
1289
|
+
} else {
|
|
1290
|
+
return res.sendError( 'No Content', 204 );
|
|
1291
|
+
}
|
|
1292
|
+
} else {
|
|
1293
|
+
return res.sendError( 'No Content', 204 );
|
|
1294
|
+
}
|
|
1295
|
+
} catch ( error ) {
|
|
1296
|
+
logger.error( error, 'getQuestions' );
|
|
1297
|
+
return res.sendError( error, 500 );
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
export async function getAnswers( req, res ) {
|
|
1301
|
+
try {
|
|
1302
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1303
|
+
let resultData = await LamdaServiceCall( url.taskAnswer, req.body );
|
|
1304
|
+
if ( resultData ) {
|
|
1305
|
+
if ( resultData.status_code == '200' ) {
|
|
1306
|
+
return res.sendSuccess( resultData );
|
|
1307
|
+
} else {
|
|
1308
|
+
return res.sendError( 'No Content', 204 );
|
|
1309
|
+
}
|
|
1310
|
+
} else {
|
|
1311
|
+
return res.sendError( 'No Content', 204 );
|
|
1312
|
+
}
|
|
1313
|
+
} catch ( error ) {
|
|
1314
|
+
logger.error( error, 'getAnswers' );
|
|
1315
|
+
return res.sendError( error, 500 );
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
export async function getAnswerCount( req, res ) {
|
|
1319
|
+
try {
|
|
1320
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1321
|
+
let resultData = await LamdaServiceCall( url.taskAnswercount, req.body );
|
|
1322
|
+
if ( resultData ) {
|
|
1323
|
+
if ( resultData.status_code == '200' ) {
|
|
1324
|
+
return res.sendSuccess( resultData );
|
|
1325
|
+
} else {
|
|
1326
|
+
return res.sendError( 'No Content', 204 );
|
|
1327
|
+
}
|
|
1328
|
+
} else {
|
|
1329
|
+
return res.sendError( 'No Content', 204 );
|
|
1330
|
+
}
|
|
1331
|
+
} catch ( error ) {
|
|
1332
|
+
logger.error( error, 'getAnswerCount' );
|
|
1333
|
+
return res.sendError( error, 500 );
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
export const taskDropdown = async ( req, res ) => {
|
|
1337
|
+
try {
|
|
1338
|
+
let requestData = req.body;
|
|
1339
|
+
|
|
1340
|
+
let result = {};
|
|
1341
|
+
|
|
1342
|
+
let findQuery = [];
|
|
1343
|
+
let findAndQuery = [];
|
|
1344
|
+
findAndQuery.push(
|
|
1345
|
+
{ client_id: requestData.clientId },
|
|
1346
|
+
// { date_iso: { $gte: fromDate } },
|
|
1347
|
+
// { date_iso: { $lte: toDate } },
|
|
1348
|
+
{ checkListType: { $in: [ 'task', 'checklistTask', 'cctv' ] } },
|
|
1349
|
+
);
|
|
1350
|
+
|
|
1351
|
+
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
1352
|
+
|
|
1353
|
+
findQuery.push( {
|
|
1354
|
+
$project: {
|
|
1355
|
+
sourceCheckList_id: 1,
|
|
1356
|
+
checkListName: 1,
|
|
1357
|
+
checkListType: 1,
|
|
1358
|
+
createdByName: 1,
|
|
1359
|
+
storeCount: 1,
|
|
1360
|
+
scheduleRepeatedType: 1,
|
|
1361
|
+
scheduleStartTime: 1,
|
|
1362
|
+
scheduleEndTime: 1,
|
|
1363
|
+
},
|
|
1364
|
+
} );
|
|
1365
|
+
|
|
1366
|
+
findQuery.push( {
|
|
1367
|
+
$group: {
|
|
1368
|
+
_id: '$sourceCheckList_id',
|
|
1369
|
+
sourceCheckList_id: { $last: '$sourceCheckList_id' },
|
|
1370
|
+
checkListName: { $last: '$checkListName' },
|
|
1371
|
+
checkListType: { $last: '$checkListType' },
|
|
1372
|
+
createdByName: { $last: '$createdByName' },
|
|
1373
|
+
storeCount: { $max: '$storeCount' },
|
|
1374
|
+
scheduleRepeatedType: { $last: '$scheduleRepeatedType' },
|
|
1375
|
+
scheduleStartTime: { $last: '$scheduleStartTime' },
|
|
1376
|
+
scheduleEndTime: { $last: '$scheduleEndTime' },
|
|
1377
|
+
},
|
|
1378
|
+
} );
|
|
1379
|
+
|
|
1380
|
+
findQuery.push( {
|
|
1381
|
+
$lookup: {
|
|
1382
|
+
from: 'checklistconfigs',
|
|
1383
|
+
let: { sourceCheckList_id: '$sourceCheckList_id' },
|
|
1384
|
+
pipeline: [
|
|
1385
|
+
{
|
|
1386
|
+
$match: {
|
|
1387
|
+
$expr: {
|
|
1388
|
+
$and: [
|
|
1389
|
+
{ $eq: [ '$_id', '$$sourceCheckList_id' ] },
|
|
1390
|
+
],
|
|
1391
|
+
},
|
|
1392
|
+
},
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
$project: {
|
|
1396
|
+
checkListName: 1,
|
|
1397
|
+
checkListDescription: 1,
|
|
1398
|
+
publish: 1,
|
|
1399
|
+
},
|
|
1400
|
+
},
|
|
1401
|
+
], as: 'checklistconfigs',
|
|
1402
|
+
},
|
|
1403
|
+
} );
|
|
1404
|
+
findQuery.push( { $unwind: { path: '$checklistconfigs', preserveNullAndEmptyArrays: true } } );
|
|
1405
|
+
findQuery.push( {
|
|
1406
|
+
$project: {
|
|
1407
|
+
sourceCheckList_id: 1,
|
|
1408
|
+
checkListName: 1,
|
|
1409
|
+
checkListType: 1,
|
|
1410
|
+
createdByName: 1,
|
|
1411
|
+
storeCount: 1,
|
|
1412
|
+
scheduleRepeatedType: 1,
|
|
1413
|
+
scheduleStartTime: 1,
|
|
1414
|
+
scheduleEndTime: 1,
|
|
1415
|
+
checkListDescription: '$checklistconfigs.checkListDescription',
|
|
1416
|
+
publish: '$checklistconfigs.publish',
|
|
1417
|
+
},
|
|
1418
|
+
} );
|
|
1419
|
+
|
|
1420
|
+
let getTotalCount = await taskProcessedConfigService.aggregate( findQuery );
|
|
1421
|
+
if ( !getTotalCount.length ) {
|
|
1422
|
+
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
1426
|
+
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
1427
|
+
} else {
|
|
1428
|
+
findQuery.push( { $sort: { ['checkListName']: -1 } } );
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
let getChecklistData = await taskProcessedConfigService.aggregate( findQuery );
|
|
1432
|
+
result.checklistData = getChecklistData;
|
|
1433
|
+
return res.sendSuccess( result );
|
|
1434
|
+
} catch ( error ) {
|
|
1435
|
+
logger.error( { error: error, message: req.query, function: 'checklistDropdown' } );
|
|
1436
|
+
return res.sendError( { error: error }, 500 );
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
@@ -2,19 +2,20 @@ import * as traxApprover from '../service/approver.service.js';
|
|
|
2
2
|
import * as processedTask from '../service/processedTaskList.service.js';
|
|
3
3
|
import { logger } from 'tango-app-api-middleware';
|
|
4
4
|
import * as processedChecklist from '../service/processedChecklist.service.js';
|
|
5
|
+
import * as checklistLog from '../service/checklistLog.service.js';
|
|
5
6
|
import mongoose from 'mongoose';
|
|
6
7
|
const ObjectId = mongoose.Types.ObjectId;
|
|
7
|
-
export const
|
|
8
|
+
export const overallCardsV1 = async ( req, res ) => {
|
|
8
9
|
try {
|
|
9
10
|
let query;
|
|
10
11
|
let taskIdList = [];
|
|
11
12
|
let checklistIdList = [];
|
|
12
13
|
let resultData;
|
|
13
|
-
if ( req?.user?.userType == 'client' && req.user.role == 'superadmin'
|
|
14
|
-
let clientId = req.user?.clientId
|
|
14
|
+
if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
|
|
15
|
+
let clientId = req.user?.clientId;
|
|
15
16
|
query = { client_id: clientId };
|
|
16
17
|
} else {
|
|
17
|
-
query = { userEmail: req.user.
|
|
18
|
+
query = { userEmail: req.user.email };
|
|
18
19
|
}
|
|
19
20
|
let details = await traxApprover.find( query );
|
|
20
21
|
if ( details.length ) {
|
|
@@ -34,7 +35,7 @@ export const overallCards = async ( req, res ) => {
|
|
|
34
35
|
].map( ( item ) => new ObjectId( item ) );
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
let toDate = new Date( req.body.
|
|
38
|
+
let toDate = new Date( req.body.toDate );
|
|
38
39
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
39
40
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
40
41
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
@@ -45,31 +46,37 @@ export const overallCards = async ( req, res ) => {
|
|
|
45
46
|
},
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
let taskQuery = [
|
|
49
50
|
{
|
|
50
51
|
$match: {
|
|
51
|
-
date_iso: { $gte: new Date( req.body.
|
|
52
|
+
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
52
53
|
sourceCheckList_id: { $in: taskIdList },
|
|
54
|
+
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
53
55
|
approvalStatus: false,
|
|
54
56
|
},
|
|
55
57
|
},
|
|
56
58
|
{ ...groupQuery },
|
|
57
59
|
];
|
|
58
|
-
let taskCount = await processedTask.aggregate( query );
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
let checklistQuery = [
|
|
61
62
|
{
|
|
62
63
|
$match: {
|
|
63
|
-
date_iso: { $gte: new Date( req.body.
|
|
64
|
+
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
64
65
|
sourceCheckList_id: { $in: checklistIdList },
|
|
66
|
+
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
65
67
|
approvalStatus: false,
|
|
66
68
|
},
|
|
67
69
|
},
|
|
68
70
|
{ ...groupQuery },
|
|
69
71
|
];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
let [ taskCount, checklistCount ] = await Promise.all( [
|
|
74
|
+
processedTask.aggregate( taskQuery ),
|
|
75
|
+
processedChecklist.aggregate( checklistQuery ),
|
|
76
|
+
] );
|
|
77
|
+
|
|
78
|
+
resultData = { taskApproval: { count: taskCount?.[0]?.count || 0 }, checklistApproval: { count: checklistCount?.[0]?.count || 0 } };
|
|
79
|
+
return res.sendSuccess( { cardData: resultData } );
|
|
73
80
|
} catch ( error ) {
|
|
74
81
|
console.log( 'error =>', error );
|
|
75
82
|
logger.error( { error: error, function: 'overallCards' } );
|
|
@@ -77,37 +84,17 @@ export const overallCards = async ( req, res ) => {
|
|
|
77
84
|
}
|
|
78
85
|
};
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
// try {
|
|
82
|
-
// let cardData = {
|
|
83
|
-
// 'checklistApproval': {
|
|
84
|
-
// 'count': 50, // Checklist Count
|
|
85
|
-
// },
|
|
86
|
-
// 'taskApproval': {
|
|
87
|
-
// 'count': 40, // Task Count
|
|
88
|
-
// },
|
|
89
|
-
// };
|
|
90
|
-
// // resultData.card = cardData;
|
|
91
|
-
// return { cardData: cardData };
|
|
92
|
-
// } catch ( error ) {
|
|
93
|
-
// console.log( 'error =>', error );
|
|
94
|
-
// logger.error( { error: error, message: data, function: 'overallCardsData' } );
|
|
95
|
-
// }
|
|
96
|
-
// }
|
|
97
|
-
|
|
98
|
-
export const approvalTable = async ( req, res ) => {
|
|
87
|
+
export const approvalTableV1 = async ( req, res ) => {
|
|
99
88
|
try {
|
|
100
89
|
let query;
|
|
101
90
|
let taskIdList = [];
|
|
102
91
|
let checklistIdList = [];
|
|
103
92
|
let resultData;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if ( req?.user?.userType == 'client' && req.user.role == 'superadmin' || req.body?.clientId ) {
|
|
107
|
-
let clientId = req.user?.clientId || req.body?.clientId;
|
|
93
|
+
if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
|
|
94
|
+
let clientId = req.user?.clientId;
|
|
108
95
|
query = { client_id: clientId };
|
|
109
96
|
} else {
|
|
110
|
-
query = { userEmail: req.user.
|
|
97
|
+
query = { userEmail: req.user.email };
|
|
111
98
|
}
|
|
112
99
|
let details = await traxApprover.find( query );
|
|
113
100
|
if ( details.length ) {
|
|
@@ -118,6 +105,7 @@ export const approvalTable = async ( req, res ) => {
|
|
|
118
105
|
.map( ( ele ) => ele.checkListId.toString() ),
|
|
119
106
|
),
|
|
120
107
|
].map( ( item ) => new ObjectId( item ) );
|
|
108
|
+
|
|
121
109
|
checklistIdList = [
|
|
122
110
|
...new Set(
|
|
123
111
|
details
|
|
@@ -127,7 +115,7 @@ export const approvalTable = async ( req, res ) => {
|
|
|
127
115
|
].map( ( item ) => new ObjectId( item ) );
|
|
128
116
|
}
|
|
129
117
|
|
|
130
|
-
let toDate = new Date( req.body.
|
|
118
|
+
let toDate = new Date( req.body.toDate );
|
|
131
119
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
132
120
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
133
121
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
@@ -176,33 +164,65 @@ export const approvalTable = async ( req, res ) => {
|
|
|
176
164
|
},
|
|
177
165
|
} ];
|
|
178
166
|
|
|
167
|
+
const promises = [];
|
|
179
168
|
|
|
180
169
|
if ( [ 'task', 'all' ].includes( req.body.type ) ) {
|
|
181
170
|
query = [
|
|
182
171
|
{
|
|
183
172
|
$match: {
|
|
184
|
-
date_iso: { $gte: new Date( req.body.
|
|
173
|
+
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
185
174
|
sourceCheckList_id: { $in: taskIdList },
|
|
175
|
+
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } :{},
|
|
186
176
|
},
|
|
187
177
|
},
|
|
188
178
|
...groupQuery,
|
|
189
179
|
];
|
|
190
|
-
|
|
180
|
+
if ( req.body?.searchValue?.trim() && req.body?.searchValue?.trim().length ) {
|
|
181
|
+
query.push( {
|
|
182
|
+
$match: {
|
|
183
|
+
checkListName: { $regex: req.body?.searchValue, $options: 'i' },
|
|
184
|
+
},
|
|
185
|
+
} );
|
|
186
|
+
}
|
|
187
|
+
if ( req.body?.filter.length ) {
|
|
188
|
+
query.push( {
|
|
189
|
+
$match: {
|
|
190
|
+
priorityType: { $in: req.body?.filter },
|
|
191
|
+
},
|
|
192
|
+
} );
|
|
193
|
+
}
|
|
194
|
+
promises.push( processedTask.aggregate( query ) );
|
|
195
|
+
} else {
|
|
196
|
+
promises.push( Promise.resolve( null ) );
|
|
191
197
|
}
|
|
198
|
+
|
|
199
|
+
|
|
192
200
|
if ( [ 'checklist', 'all' ].includes( req.body.type ) ) {
|
|
193
201
|
query = [
|
|
194
202
|
{
|
|
195
203
|
$match: {
|
|
196
|
-
date_iso: { $gte: new Date( req.body.
|
|
204
|
+
date_iso: { $gte: new Date( req.body.fromDate ), $lte: toDate },
|
|
197
205
|
sourceCheckList_id: { $in: checklistIdList },
|
|
206
|
+
...( req.body?.storeId?.length ) ? { store_id: { $in: req.body.storeId } } : {},
|
|
198
207
|
},
|
|
199
208
|
},
|
|
200
209
|
...groupQuery,
|
|
201
210
|
];
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
promises.push( processedChecklist.aggregate( query ) );
|
|
212
|
+
if ( req.body?.searchValue.trim() && req.body?.searchValue.trim().length ) {
|
|
213
|
+
query.push( {
|
|
214
|
+
$match: {
|
|
215
|
+
checkListName: { $regex: req.body?.searchValue, $options: 'i' },
|
|
216
|
+
},
|
|
217
|
+
} );
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
promises.push( Promise.resolve( null ) );
|
|
204
221
|
}
|
|
205
|
-
|
|
222
|
+
|
|
223
|
+
const [ taskResult, checklistResult ] = await Promise.all( promises );
|
|
224
|
+
|
|
225
|
+
const taskSummary = taskResult?.reduce(
|
|
206
226
|
( acc, ele ) => {
|
|
207
227
|
if ( ele.unApproveCount === ele.storeCount ) {
|
|
208
228
|
acc.openTask.push( ele );
|
|
@@ -215,9 +235,9 @@ export const approvalTable = async ( req, res ) => {
|
|
|
215
235
|
},
|
|
216
236
|
{ openTask: [], inprogressTask: [], doneTask: [] },
|
|
217
237
|
);
|
|
218
|
-
const { openTask, inprogressTask, doneTask } = taskSummary;
|
|
238
|
+
const { openTask, inprogressTask, doneTask } = taskSummary || { openTask: [], inprogressTask: [], doneTask: [] };
|
|
219
239
|
|
|
220
|
-
const checklistSummary = checklistResult
|
|
240
|
+
const checklistSummary = checklistResult?.reduce(
|
|
221
241
|
( acc, ele ) => {
|
|
222
242
|
if ( ele.unApproveCount === ele.storeCount ) {
|
|
223
243
|
acc.openChecklist.push( ele );
|
|
@@ -230,7 +250,7 @@ export const approvalTable = async ( req, res ) => {
|
|
|
230
250
|
},
|
|
231
251
|
{ openChecklist: [], inprogressChecklist: [], doneChecklist: [] },
|
|
232
252
|
);
|
|
233
|
-
const { openChecklist, inprogressChecklist, doneChecklist } = checklistSummary;
|
|
253
|
+
const { openChecklist, inprogressChecklist, doneChecklist } = checklistSummary || { openChecklist: [], inprogressChecklist: [], doneChecklist: [] };
|
|
234
254
|
|
|
235
255
|
resultData = { open: [ ...openTask, ...openChecklist ], inprogress: [ ...inprogressTask, ...inprogressChecklist ], done: [ ...doneTask, ...doneChecklist ] };
|
|
236
256
|
|
|
@@ -241,72 +261,167 @@ export const approvalTable = async ( req, res ) => {
|
|
|
241
261
|
}
|
|
242
262
|
};
|
|
243
263
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
264
|
+
export const activityLogV1 = async ( req, res ) => {
|
|
265
|
+
try {
|
|
266
|
+
let requestData = req.body;
|
|
267
|
+
let findQuery = [];
|
|
268
|
+
let findAndQuery = [];
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
findAndQuery.push(
|
|
272
|
+
{ client_id: requestData.clientId },
|
|
273
|
+
{ store_id: { $in: requestData.storeId } },
|
|
274
|
+
{ action: { $in: [ 'submitted', 'started' ] } },
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
279
|
+
findQuery.push( {
|
|
280
|
+
$project: {
|
|
281
|
+
checkListName: 1,
|
|
282
|
+
storeName: 1,
|
|
283
|
+
action: 1,
|
|
284
|
+
createdAt: 1,
|
|
285
|
+
type: 1,
|
|
286
|
+
},
|
|
287
|
+
} );
|
|
288
|
+
let limit = parseInt( requestData?.limit ) || 10;
|
|
289
|
+
let skip = limit * ( requestData?.offset -1 ) || 0;
|
|
290
|
+
|
|
291
|
+
findQuery.push( {
|
|
292
|
+
$facet: {
|
|
293
|
+
activityLogData: [
|
|
294
|
+
{ $skip: skip },
|
|
295
|
+
{ $limit: limit },
|
|
296
|
+
],
|
|
297
|
+
count: [
|
|
298
|
+
{ $count: 'total' },
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
} );
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
let activityLogData = await checklistLog.aggregate( findQuery );
|
|
305
|
+
|
|
306
|
+
if ( activityLogData && activityLogData.length > 0 ) {
|
|
307
|
+
return res.sendSuccess( activityLogData );
|
|
308
|
+
} else {
|
|
309
|
+
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
310
|
+
}
|
|
311
|
+
} catch ( error ) {
|
|
312
|
+
logger.error( { error: error, function: 'activityLogV1' } );
|
|
313
|
+
return res.sendError( error, 500 );
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export const overallCards = async ( req, res ) => {
|
|
318
|
+
try {
|
|
319
|
+
let requestData = req.body;
|
|
320
|
+
let resultData = await overallCardsData( requestData );
|
|
321
|
+
return res.sendSuccess( resultData );
|
|
322
|
+
} catch ( error ) {
|
|
323
|
+
console.log( 'error =>', error );
|
|
324
|
+
logger.error( { error: error, function: 'overallCards' } );
|
|
325
|
+
return res.sendError( error, 500 );
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
async function overallCardsData( requestData ) {
|
|
330
|
+
try {
|
|
331
|
+
let cardData = {
|
|
332
|
+
'checklistApproval': {
|
|
333
|
+
'count': 50, // Checklist Count
|
|
334
|
+
},
|
|
335
|
+
'taskApproval': {
|
|
336
|
+
'count': 40, // Task Count
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
// resultData.card = cardData;
|
|
340
|
+
return { cardData: cardData };
|
|
341
|
+
} catch ( error ) {
|
|
342
|
+
console.log( 'error =>', error );
|
|
343
|
+
logger.error( { error: error, message: data, function: 'overallCardsData' } );
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export const approvalTable = async ( req, res ) => {
|
|
348
|
+
try {
|
|
349
|
+
let requestData = req.body;
|
|
350
|
+
let resultData = await approvalTableData( requestData );
|
|
351
|
+
return res.sendSuccess( resultData );
|
|
352
|
+
} catch ( error ) {
|
|
353
|
+
console.log( 'error =>', error );
|
|
354
|
+
logger.error( { error: error, function: 'taskTable' } );
|
|
355
|
+
return res.sendError( error, 500 );
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
async function approvalTableData( requestData ) {
|
|
360
|
+
try {
|
|
361
|
+
let tableData = {
|
|
362
|
+
'totalCount': 50,
|
|
363
|
+
'approvalList': [
|
|
364
|
+
{
|
|
365
|
+
'taskName': 'Hustlr Tray',
|
|
366
|
+
'createdBy': 'Olivia Rhye',
|
|
367
|
+
'totalAssigned': 100,
|
|
368
|
+
'totalSubmitted': 200,
|
|
369
|
+
'scheduledRepeatedType': 'daily', // weekly or monthly,
|
|
370
|
+
'dateString': '12 Jan,2024',
|
|
371
|
+
'sorceTaskId': '4862896912909',
|
|
372
|
+
'taskType': 'task', // checklist or redo
|
|
373
|
+
'status': 'open', // inprogress or approved
|
|
374
|
+
'priority': 'high',
|
|
375
|
+
'approved': 90,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
'taskName': 'Hustlr Tray',
|
|
379
|
+
'createdBy': 'Olivia Rhye',
|
|
380
|
+
'totalAssigned': 100,
|
|
381
|
+
'totalSubmitted': 200,
|
|
382
|
+
'scheduledRepeatedType': 'daily', // weekly or monthly,
|
|
383
|
+
'dateString': '12 Jan,2024',
|
|
384
|
+
'sorceTaskId': '4862896912909',
|
|
385
|
+
'taskType': 'redo', // checklist or redo
|
|
386
|
+
'status': 'inprogress', // inprogress or approved
|
|
387
|
+
'priority': 'low',
|
|
388
|
+
'approved': 90,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
'taskName': 'Hustlr Tray',
|
|
392
|
+
'createdBy': 'Olivia Rhye',
|
|
393
|
+
'totalAssigned': 100,
|
|
394
|
+
'totalSubmitted': 200,
|
|
395
|
+
'scheduledRepeatedType': 'daily', // weekly or monthly,
|
|
396
|
+
'dateString': '12 Jan,2024',
|
|
397
|
+
'sorceTaskId': '4862896912909',
|
|
398
|
+
'taskType': 'task', // checklist or redo
|
|
399
|
+
'status': 'approved', // inprogress or approved
|
|
400
|
+
'priority': 'low',
|
|
401
|
+
'approved': 90,
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
'taskName': 'Hustlr Tray',
|
|
405
|
+
'createdBy': 'Olivia Rhye',
|
|
406
|
+
'totalAssigned': 100,
|
|
407
|
+
'totalSubmitted': 200,
|
|
408
|
+
'scheduledRepeatedType': 'daily', // weekly or monthly,
|
|
409
|
+
'dateString': '12 Jan,2024',
|
|
410
|
+
'sorceTaskId': '4862896912909',
|
|
411
|
+
'taskType': 'task', // checklist or redo
|
|
412
|
+
'status': 'approved', // inprogress or approved
|
|
413
|
+
'priority': 'low',
|
|
414
|
+
'approved': 90,
|
|
415
|
+
},
|
|
416
|
+
],
|
|
417
|
+
};
|
|
418
|
+
return tableData;
|
|
419
|
+
} catch ( error ) {
|
|
420
|
+
console.log( 'error =>', error );
|
|
421
|
+
logger.error( { error: error, message: requestData, function: 'approvalTableData' } );
|
|
422
|
+
return res.sendError( error, 500 );
|
|
423
|
+
}
|
|
424
|
+
}
|
|
310
425
|
|
|
311
426
|
export const activityLog = async ( req, res ) => {
|
|
312
427
|
try {
|
|
@@ -319,6 +434,7 @@ export const activityLog = async ( req, res ) => {
|
|
|
319
434
|
return res.sendError( error, 500 );
|
|
320
435
|
}
|
|
321
436
|
};
|
|
437
|
+
|
|
322
438
|
async function activityLogData( requestData ) {
|
|
323
439
|
try {
|
|
324
440
|
let activityLogData = {
|
|
@@ -58,7 +58,6 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
58
58
|
let findAndQuery = [];
|
|
59
59
|
|
|
60
60
|
findAndQuery.push(
|
|
61
|
-
{ checkListType: { $eq: 'task' } },
|
|
62
61
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
63
62
|
{ client_id: requestData.clientId },
|
|
64
63
|
{ store_id: { $in: requestData.storeId } },
|
|
@@ -67,7 +66,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
67
66
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
68
67
|
findQuery.push( {
|
|
69
68
|
$group: {
|
|
70
|
-
_id: '$checklistStatus',
|
|
69
|
+
_id: { status: '$checklistStatus', redoType: '$redoStatus', approvalStatus: '$approvalStatus' },
|
|
71
70
|
count: { $sum: 1 },
|
|
72
71
|
},
|
|
73
72
|
},
|
|
@@ -75,11 +74,11 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
75
74
|
$group: {
|
|
76
75
|
_id: null,
|
|
77
76
|
TotalTasks: { $sum: '$count' },
|
|
78
|
-
open: { $sum: { $cond: [ { $eq: [ '$_id', 'open' ] }, '$count', 0 ] } },
|
|
79
|
-
inprogress: { $sum: { $cond: [ { $eq: [ '$_id', 'inprogress' ] }, '$count', 0 ] } },
|
|
80
|
-
reopen: { $sum: { $cond: [ { $eq: [ '$_id', '
|
|
81
|
-
submitted: { $sum: { $cond: [ { $eq: [ '$_id', 'submit' ] }, '$count', 0 ] } },
|
|
82
|
-
closed: { $sum: { $cond: [ { $eq: [ '$_id', '
|
|
77
|
+
open: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'open' ] }, { $eq: [ '$_id.redoType', false ] } ] }, '$count', 0 ] } },
|
|
78
|
+
inprogress: { $sum: { $cond: [ { $eq: [ '$_id.status', 'inprogress' ] }, '$count', 0 ] } },
|
|
79
|
+
reopen: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'open' ] }, { $eq: [ '$_id.redoType', true ] } ] }, '$count', 0 ] } },
|
|
80
|
+
submitted: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'submit' ] }, { $eq: [ '$_id.approvalStatus', false ] } ] }, '$count', 0 ] } },
|
|
81
|
+
closed: { $sum: { $cond: [ { $and: [ { $eq: [ '$_id.status', 'submit' ] }, { $eq: [ '$_id.approvalStatus', true ] } ] }, '$count', 0 ] } },
|
|
83
82
|
},
|
|
84
83
|
},
|
|
85
84
|
{
|
|
@@ -112,7 +111,7 @@ export const taskTableV1 = async ( req, res ) => {
|
|
|
112
111
|
query.push(
|
|
113
112
|
{
|
|
114
113
|
$match: {
|
|
115
|
-
checkListType: 'task',
|
|
114
|
+
// checkListType: 'task',
|
|
116
115
|
client_id: req.body.clientId,
|
|
117
116
|
isdeleted: false,
|
|
118
117
|
},
|
|
@@ -230,11 +229,10 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
230
229
|
let findAndQuery = [];
|
|
231
230
|
|
|
232
231
|
findAndQuery.push(
|
|
232
|
+
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
233
233
|
{ client_id: requestData.clientId },
|
|
234
234
|
{ store_id: { $in: requestData.storeId } },
|
|
235
|
-
{
|
|
236
|
-
{ date_iso: { $lte: toDate } },
|
|
237
|
-
{ checkListType: { $eq: 'task' } },
|
|
235
|
+
// { checkListType: { $eq: 'task' } },
|
|
238
236
|
{ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.taskId ) },
|
|
239
237
|
);
|
|
240
238
|
if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
|
|
@@ -315,12 +313,6 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
315
313
|
},
|
|
316
314
|
} );
|
|
317
315
|
|
|
318
|
-
let getTotalCount = await processedTaskService.aggregate( findQuery );
|
|
319
|
-
console.log( 'getTotalCount', getTotalCount );
|
|
320
|
-
if ( !getTotalCount.length ) {
|
|
321
|
-
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
322
|
-
}
|
|
323
|
-
|
|
324
316
|
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
325
317
|
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
326
318
|
} else {
|
|
@@ -329,14 +321,30 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
329
321
|
|
|
330
322
|
let limit = parseInt( requestData?.limit ) || 10;
|
|
331
323
|
let skip = limit * ( requestData?.offset -1 ) || 0;
|
|
332
|
-
|
|
324
|
+
|
|
325
|
+
findQuery.push( {
|
|
326
|
+
$facet: {
|
|
327
|
+
data: [
|
|
328
|
+
{ $skip: skip },
|
|
329
|
+
{ $limit: limit },
|
|
330
|
+
],
|
|
331
|
+
count: [
|
|
332
|
+
{ $count: 'total' },
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
} );
|
|
336
|
+
|
|
333
337
|
let taskInfoData = await processedTaskService.aggregate( findQuery );
|
|
334
338
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
339
|
+
if ( !taskInfoData[0].data.length ) {
|
|
340
|
+
return res.sendError( 'no data found', 204 );
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
result.totalCount = taskInfoData[0].count[0].total;
|
|
344
|
+
for ( let i = 0; i < taskInfoData[0].data.length; i++ ) {
|
|
345
|
+
taskInfoData[0].data[i].scheduleEndTime_iso = dayjs( taskInfoData[0].data[i].scheduleEndTime_iso ).format( 'DD MMM YYYY' );
|
|
338
346
|
}
|
|
339
|
-
result.taskInfo = taskInfoData;
|
|
347
|
+
result.taskInfo = taskInfoData[0].data;
|
|
340
348
|
return res.sendSuccess( result );
|
|
341
349
|
} catch ( error ) {
|
|
342
350
|
console.log( 'error =>', error );
|
|
@@ -668,7 +676,8 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
668
676
|
let findAndQuery = [];
|
|
669
677
|
findAndQuery.push(
|
|
670
678
|
{ client_id: requestData.clientId },
|
|
671
|
-
{ checkListType: 'task' },
|
|
679
|
+
// { checkListType: 'task' },
|
|
680
|
+
{ isdeleted: false },
|
|
672
681
|
);
|
|
673
682
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
674
683
|
findQuery.push( {
|
|
@@ -680,6 +689,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
680
689
|
createdByName: 1,
|
|
681
690
|
storeCount: 1,
|
|
682
691
|
scheduleEndTimeISO: 1,
|
|
692
|
+
submitTime_string: 1,
|
|
683
693
|
},
|
|
684
694
|
} );
|
|
685
695
|
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
@@ -745,3 +755,35 @@ async function taskInfoViewData( requestData ) {
|
|
|
745
755
|
return res.sendError( error, 500 );
|
|
746
756
|
}
|
|
747
757
|
}
|
|
758
|
+
export const taskDeleteV1 = async ( req, res ) => {
|
|
759
|
+
try {
|
|
760
|
+
let requestData = req.body;
|
|
761
|
+
|
|
762
|
+
if ( !requestData.taskId ) {
|
|
763
|
+
return res.sendError( 'Missing taskId in request body', 400 );
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const taskConfig = await taskService.findOne( { _id: new mongoose.Types.ObjectId( requestData.taskId ) }, { _id: 1 } );
|
|
767
|
+
if ( !taskConfig ) {
|
|
768
|
+
console.log( 'Task found:', taskConfig );
|
|
769
|
+
return res.sendError( 'Task not found', 404 );
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
let resultData = await taskService.updateOne(
|
|
773
|
+
{ _id: new mongoose.Types.ObjectId( requestData.taskId ) },
|
|
774
|
+
{ isdeleted: true },
|
|
775
|
+
);
|
|
776
|
+
|
|
777
|
+
if ( resultData ) {
|
|
778
|
+
console.log( 'Update result:', resultData );
|
|
779
|
+
return res.sendSuccess( { message: 'Task deleted successfully' } );
|
|
780
|
+
} else {
|
|
781
|
+
return res.sendError( 'Something went wrong please try again', 500 );
|
|
782
|
+
}
|
|
783
|
+
} catch ( e ) {
|
|
784
|
+
logger.error( 'taskDeleteV1 =>', e );
|
|
785
|
+
return res.sendError( e, 500 );
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
|
|
@@ -14,6 +14,12 @@ taskRouter
|
|
|
14
14
|
.post( '/uploadImage', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.uploadImage )
|
|
15
15
|
.post( '/config', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.taskConfig )
|
|
16
16
|
.post( '/reinitiate', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.reinitiateTask )
|
|
17
|
-
.post( '/checklistTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistTask )
|
|
17
|
+
.post( '/checklistTask', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.createChecklistTask )
|
|
18
|
+
.post( '/updateApprove', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.approveTask )
|
|
19
|
+
.post( '/redo', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.redoTask )
|
|
20
|
+
.post( '/taskDropdown', isAllowedSessionHandler, taskController.taskDropdown )
|
|
21
|
+
.post( '/getQuestions', isAllowedSessionHandler, taskController.getQuestions )
|
|
22
|
+
.post( '/getAnswers', isAllowedSessionHandler, taskController.getAnswers )
|
|
23
|
+
.post( '/getAnswerCount', isAllowedSessionHandler, taskController.getAnswerCount );
|
|
18
24
|
|
|
19
25
|
|
|
@@ -3,14 +3,16 @@ import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
|
3
3
|
export const taskActionCenterRouter = express.Router();
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
overallCards, approvalTable, activityLog,
|
|
6
|
+
overallCards, approvalTable, activityLog, overallCardsV1, approvalTableV1, activityLogV1,
|
|
7
7
|
} from '../controllers/taskActionCenter.controllers.js';
|
|
8
8
|
|
|
9
9
|
taskActionCenterRouter
|
|
10
|
-
.post( '/
|
|
11
|
-
|
|
12
|
-
.post( '/
|
|
13
|
-
|
|
14
|
-
.post( '/activityLog', activityLog )
|
|
10
|
+
.post( '/overallcardsV1', isAllowedSessionHandler, overallCardsV1 )
|
|
11
|
+
.post( '/overallcards', overallCards )
|
|
12
|
+
.post( '/approvalTableV1', isAllowedSessionHandler, approvalTableV1 )
|
|
13
|
+
.post( '/approvalTable', approvalTable )
|
|
14
|
+
.post( '/activityLog', activityLog )
|
|
15
|
+
.post( '/activityLogV1', isAllowedSessionHandler, activityLogV1 );
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
export default taskActionCenterRouter;
|
|
@@ -2,7 +2,7 @@ import express from 'express';
|
|
|
2
2
|
export const taskDashboardRouter = express.Router();
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1,
|
|
5
|
+
overallCards, taskTable, taskInfoTable, taskDropdownList, taskTableV1, overallCardsV1, taskInfoTableV1, taskDropdownListV1, taskDeleteV1,
|
|
6
6
|
} from '../controllers/taskDashboard.controllers.js';
|
|
7
7
|
|
|
8
8
|
taskDashboardRouter
|
|
@@ -13,6 +13,7 @@ taskDashboardRouter
|
|
|
13
13
|
.post( '/taskInfoTable', taskInfoTable )
|
|
14
14
|
.post( '/taskInfoTableV1', taskInfoTableV1 )
|
|
15
15
|
.post( '/taskDropdownList', taskDropdownList )
|
|
16
|
-
.post( '/taskDropdownListV1', taskDropdownListV1 )
|
|
16
|
+
.post( '/taskDropdownListV1', taskDropdownListV1 )
|
|
17
|
+
.post( '/taskDeleteV1', taskDeleteV1 );
|
|
17
18
|
|
|
18
19
|
export default taskDashboardRouter;
|
|
@@ -4,3 +4,11 @@ export const aggregate = ( query = [] ) => {
|
|
|
4
4
|
return model.processedchecklistModel.aggregate( query );
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
export const findOne = ( query = {}, field = {} ) => {
|
|
8
|
+
return model.processedchecklistModel.findOne( query, field );
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const updateOne = ( query = {}, record = {} ) => {
|
|
12
|
+
return model.processedchecklistModel.updateOne( query, { $set: record } );
|
|
13
|
+
};
|
|
14
|
+
|
|
@@ -12,6 +12,10 @@ export const updateMany = async ( query = {}, record={} ) => {
|
|
|
12
12
|
return model.taskProcessedModel.updateMany( query, { $set: record } );
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export const updateOne = async ( query = {}, record={} ) => {
|
|
16
|
+
return model.taskProcessedModel.updateOne( query, { $set: record } );
|
|
17
|
+
};
|
|
18
|
+
|
|
15
19
|
export const insertMany = async ( data = [] ) => {
|
|
16
20
|
return model.taskProcessedModel.insertMany( data );
|
|
17
21
|
};
|