tango-app-api-task 1.0.0-beta.9 → 1.1.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-task",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Task",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"mongodb": "^6.10.0",
|
|
25
25
|
"nodemon": "^3.1.7",
|
|
26
26
|
"npm": "^10.9.2",
|
|
27
|
-
"tango-api-schema": "2.2.
|
|
28
|
-
"tango-app-api-middleware": "3.1.43-alpha.10",
|
|
27
|
+
"tango-api-schema": "^2.2.10",
|
|
28
|
+
"tango-app-api-middleware": "^3.1.43-alpha.10",
|
|
29
29
|
"winston": "^3.17.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
31
|
},
|
|
@@ -753,15 +753,15 @@ export async function taskConfig( req, res ) {
|
|
|
753
753
|
let tDate = dayjs().format( 'YYYY-MM-DD' ) + ' ' + dayjs().format( 'hh:mm A' );
|
|
754
754
|
let currentDate = dayjs( tDate, 'YYYY-MM-DD hh:mm A' ).format();
|
|
755
755
|
if ( configDetails.scheduleEndTimeISO >= currentDate ) {
|
|
756
|
-
let deleteQuery = {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
};
|
|
763
|
-
deleteQuery.$and.push( { checklistStatus: { $ne: 'submit' } } );
|
|
764
|
-
await taskProcessedService.deleteMany( deleteQuery );
|
|
756
|
+
// let deleteQuery = {
|
|
757
|
+
// $and: [
|
|
758
|
+
// { date_string: dayjs().format( 'YYYY-MM-DD' ) },
|
|
759
|
+
// { sourceCheckList_id: new ObjectId( req.params.checklistId ) },
|
|
760
|
+
// { scheduleEndTime_iso: { $gt: currentDate } },
|
|
761
|
+
// ],
|
|
762
|
+
// };
|
|
763
|
+
// deleteQuery.$and.push( { checklistStatus: { $ne: 'submit' } } );
|
|
764
|
+
// await taskProcessedService.deleteMany( deleteQuery );
|
|
765
765
|
await insertSingleProcessData( inputBody._id );
|
|
766
766
|
} else {
|
|
767
767
|
logger.info( `Schudled End Time Breached Checklist publish true => Checklist Name: ${checklistDetails.checkListName}` );
|
|
@@ -823,6 +823,7 @@ export async function insertSingleProcessData( checklistId ) {
|
|
|
823
823
|
insertdata.scheduleRepeatedType = 'daily';
|
|
824
824
|
insertdata.remainder = getCLconfig?.remainder || [];
|
|
825
825
|
insertdata.approver = getCLconfig?.approver || [];
|
|
826
|
+
insertdata.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
826
827
|
let collectSections = [];
|
|
827
828
|
let sectionQuery = [];
|
|
828
829
|
sectionQuery.push( {
|
|
@@ -914,6 +915,7 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
|
|
|
914
915
|
} );
|
|
915
916
|
let allQuestion = await taskAssignService.aggregate( getquestionQuery );
|
|
916
917
|
|
|
918
|
+
|
|
917
919
|
if ( allQuestion ) {
|
|
918
920
|
let userIdList = [];
|
|
919
921
|
for ( let element4 of allQuestion ) {
|
|
@@ -962,20 +964,42 @@ async function insertPCBulkV3( getCLconfig, checklistId, updatedchecklist, date,
|
|
|
962
964
|
element4.approvalEnable = getCLconfig.approver.length ? true : false;
|
|
963
965
|
element4.priorityType = getCLconfig.priorityType;
|
|
964
966
|
element4.remainder = getCLconfig?.remainder || [];
|
|
967
|
+
element4.restrictAttendance = getCLconfig?.restrictAttendance;
|
|
965
968
|
}
|
|
966
969
|
if ( userIdList.length ) {
|
|
967
970
|
allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
|
|
968
971
|
}
|
|
972
|
+
|
|
969
973
|
if ( allQuestion ) {
|
|
970
|
-
let assigndeletequery = {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
974
|
+
let assigndeletequery = {
|
|
975
|
+
date_iso: date,
|
|
976
|
+
client_id: insertdata.client_id,
|
|
977
|
+
checkListId: updatedchecklist._id,
|
|
978
|
+
redoStatus: false,
|
|
979
|
+
checklistStatus: { $nin: [ 'submit' ] },
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
if ( assigndeletequery.checkListId && assigndeletequery.date_iso ) {
|
|
983
|
+
await taskProcessedService.deleteMany( assigndeletequery );
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const retainTaskQuery = {
|
|
987
|
+
date_iso: date,
|
|
988
|
+
client_id: insertdata.client_id,
|
|
989
|
+
checkListId: updatedchecklist._id,
|
|
990
|
+
redoStatus: true,
|
|
991
|
+
checklistStatus: { $nin: [ 'submit' ] },
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
const taskToRetain = await taskProcessedService.find( retainTaskQuery );
|
|
995
|
+
|
|
996
|
+
const insertList = allQuestion.filter( ( item2 ) =>
|
|
997
|
+
!taskToRetain.some( ( item1 ) =>
|
|
998
|
+
item1.store_id === item2.store_id && item1.userEmail === item2.userEmail,
|
|
999
|
+
),
|
|
1000
|
+
);
|
|
1001
|
+
|
|
1002
|
+
await taskProcessedService.insertMany( insertList );
|
|
979
1003
|
logger.info( { function: 'insertPCBulk_v3', query: assigndeletequery } );
|
|
980
1004
|
}
|
|
981
1005
|
}
|
|
@@ -1059,24 +1083,14 @@ export async function reinitiateTask( req, res ) {
|
|
|
1059
1083
|
if ( !taskDetails ) {
|
|
1060
1084
|
return res.sendError( 'no data found', 204 );
|
|
1061
1085
|
}
|
|
1062
|
-
let data = {};
|
|
1063
1086
|
let endDate = dayjs( req.body.scheduleDate ).format( 'YYYY-MM-DD' ) + ' ' + req.body.scheduleEndTime;
|
|
1064
1087
|
endDate = dayjs.utc( endDate, 'YYYY-MM-DD hh:mm A' ).format();
|
|
1065
|
-
data.scheduleDate = req.body.scheduleDate;
|
|
1066
|
-
data.scheduleEndTime = req.body.scheduleEndTime;
|
|
1067
|
-
data.scheduleEndTimeISO = endDate;
|
|
1068
|
-
data.allowedStoreLocation = req.body.allowedStoreLocation;
|
|
1069
|
-
data.approver = req.body.approver;
|
|
1070
|
-
data.priorityType = req.body.priorityType;
|
|
1071
|
-
data.restrictAttendance = req.body.restrictAttendance;
|
|
1072
|
-
data.reinitiate = true;
|
|
1073
1088
|
|
|
1074
1089
|
if ( req.body?.approver.length ) {
|
|
1075
1090
|
let data = [];
|
|
1076
1091
|
let existEmail = await traxApprover.find( { checkListId: req.body.taskId, isdeleted: false } );
|
|
1077
1092
|
let mailList = existEmail.map( ( item ) => item.userEmail );
|
|
1078
1093
|
existEmail = req.body?.approver.filter( ( item ) => mailList.includes( item.value ) ).map( ( item ) => item.value );
|
|
1079
|
-
let userMailList = req.body?.approver.map( ( ele ) => ele.value );
|
|
1080
1094
|
req.body?.approver.forEach( ( ele ) => {
|
|
1081
1095
|
if ( !existEmail.includes( ele.value ) ) {
|
|
1082
1096
|
data.push( {
|
|
@@ -1087,14 +1101,11 @@ export async function reinitiateTask( req, res ) {
|
|
|
1087
1101
|
} );
|
|
1088
1102
|
}
|
|
1089
1103
|
} );
|
|
1090
|
-
|
|
1091
|
-
await traxApprover.updateMany( { checkListId: req.body.taskId, userEmail: { $nin: userMailList } }, { isdeleted: true } );
|
|
1092
1104
|
if ( data.length ) {
|
|
1093
1105
|
await traxApprover.insertMany( data );
|
|
1094
1106
|
}
|
|
1095
1107
|
}
|
|
1096
1108
|
|
|
1097
|
-
await taskService.updateOne( { _id: req.body.taskId }, data );
|
|
1098
1109
|
function getDaysBeforeEndDate( endDate ) {
|
|
1099
1110
|
const end = dayjs.utc( endDate );
|
|
1100
1111
|
const now = dayjs.utc( req.body.previousEndDate ).add( 1, 'day' );
|
|
@@ -1112,8 +1123,8 @@ export async function reinitiateTask( req, res ) {
|
|
|
1112
1123
|
};
|
|
1113
1124
|
|
|
1114
1125
|
const dateArray = getDaysBeforeEndDate( endDate );
|
|
1115
|
-
await taskProcessedService.updateMany( { userEmail: req.body.userEmail, store_id: req.body.store_id, date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, sourceCheckList_id: req.body.taskId }, { scheduleEndTime_iso: endDate } );
|
|
1116
|
-
await taskProcessedConfigService.updateMany( { date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, sourceCheckList_id: req.body.taskId }, { scheduleEndTime_iso: endDate } );
|
|
1126
|
+
await taskProcessedService.updateMany( { userEmail: req.body.userEmail, store_id: req.body.store_id, date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, sourceCheckList_id: req.body.taskId }, { scheduleEndTime_iso: endDate, priorityType: req.body.priorityType, allowedStoreLocation: req.body.allowedStoreLocation, restrictAttendance: req.body.restrictAttendance } );
|
|
1127
|
+
await taskProcessedConfigService.updateMany( { date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, sourceCheckList_id: req.body.taskId }, { scheduleEndTime_iso: endDate, priorityType: req.body.priorityType, allowedStoreLocation: req.body.allowedStoreLocation } );
|
|
1117
1128
|
|
|
1118
1129
|
if ( dateArray.length ) {
|
|
1119
1130
|
let getPreviousUserTaskDate = await taskProcessedService.findOne( { userEmail: req.body.userEmail, store_id: req.body.store_id, sourceCheckList_id: req.body.taskId } );
|
|
@@ -1196,14 +1207,6 @@ export async function createChecklistTask( req, res ) {
|
|
|
1196
1207
|
data['approver'] = { name: req.user.userName, value: req.user.email };
|
|
1197
1208
|
}
|
|
1198
1209
|
|
|
1199
|
-
let taskNameDetails = await taskService.find( { checkListName: { $regex: data.checkListName, $options: 'i' }, client_id: data.client_id, isdeleted: false } );
|
|
1200
|
-
if ( taskNameDetails.length ) {
|
|
1201
|
-
let nameLength = taskNameDetails.length;
|
|
1202
|
-
data.checkListName = data.checkListName.split( '(' )[0] + '(' + nameLength +')';
|
|
1203
|
-
} else {
|
|
1204
|
-
data.checkListName = data.checkListName;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
1210
|
let response = await taskService.create( data );
|
|
1208
1211
|
if ( response?.approver.length ) {
|
|
1209
1212
|
let data = [];
|
|
@@ -1213,6 +1216,7 @@ export async function createChecklistTask( req, res ) {
|
|
|
1213
1216
|
checkListId: response._id,
|
|
1214
1217
|
type: 'task',
|
|
1215
1218
|
client_id: inputBody.clientId,
|
|
1219
|
+
checkListName: inputBody?.checkListName || '',
|
|
1216
1220
|
} );
|
|
1217
1221
|
} );
|
|
1218
1222
|
await traxApprover.insertMany( data );
|
|
@@ -1326,43 +1330,49 @@ export async function approveTask( req, res ) {
|
|
|
1326
1330
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
1327
1331
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
1328
1332
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
1329
|
-
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, checklistStatus: 'submit', approvalEnable: true };
|
|
1333
|
+
let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
|
|
1330
1334
|
if ( req.body?.storeId?.length ) {
|
|
1331
1335
|
query['store_id'] = { $in: req.body.storeId };
|
|
1332
1336
|
}
|
|
1333
|
-
let taskDetails = await taskProcessedService.find( query, { _id: 1 }
|
|
1337
|
+
let taskDetails = await taskProcessedService.find( query, { _id: 1, checklistStatus: 1, storeName: 1, store_id: 1, userEmail: 1 });
|
|
1334
1338
|
if ( !taskDetails.length ) {
|
|
1335
1339
|
return res.sendError( 'No data found', 204 );
|
|
1336
1340
|
}
|
|
1337
|
-
let idList = taskDetails.map( ( item ) => item._id );
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
'
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1341
|
+
let idList = taskDetails.filter( ( ele ) => ele.checklistStatus == 'submit' ).map( ( item ) => item._id );
|
|
1342
|
+
if ( idList.length ) {
|
|
1343
|
+
let updateResponse = await taskProcessedService.updateMany( { _id: { $in: idList } }, { approvalStatus: true } );
|
|
1344
|
+
if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
|
|
1345
|
+
let inputstores = taskDetails.filter( ( data ) => data.checklistStatus == 'submit' );
|
|
1346
|
+
let params = {
|
|
1347
|
+
'payload': {
|
|
1348
|
+
sourceCheckList_id: req.body.sourceCheckList_id,
|
|
1349
|
+
fromDate: req.body.fromDate,
|
|
1350
|
+
toDate: req.body.toDate,
|
|
1351
|
+
store_id: inputstores,
|
|
1352
|
+
},
|
|
1353
|
+
'upsert': {
|
|
1354
|
+
approvalStatus: true,
|
|
1355
|
+
},
|
|
1356
|
+
};
|
|
1357
|
+
const requestOptions = {
|
|
1358
|
+
method: 'POST',
|
|
1359
|
+
headers: {
|
|
1360
|
+
'Content-Type': 'application/json',
|
|
1361
|
+
},
|
|
1362
|
+
body: JSON.stringify( params ),
|
|
1363
|
+
};
|
|
1364
|
+
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1359
1365
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1366
|
+
let searchResponse = await fetch( url.approveTask, requestOptions );
|
|
1367
|
+
if ( searchResponse.ok ) {
|
|
1368
|
+
return res.sendSuccess( 'Task has been approved the submitted stores' );
|
|
1369
|
+
} else {
|
|
1370
|
+
return res.sendError( 'Something went wrong', 500 );
|
|
1371
|
+
}
|
|
1365
1372
|
}
|
|
1373
|
+
} else {
|
|
1374
|
+
let redoList = taskDetails.filter( ( ele ) => ele.checklistStatus == 'open' );
|
|
1375
|
+
return res.sendError( `${redoList.length} stores has not been approved since those stores are not submitted`, 400 );
|
|
1366
1376
|
}
|
|
1367
1377
|
} catch ( e ) {
|
|
1368
1378
|
logger.error( { function: 'approveTask', error: e, message: req.body } );
|
|
@@ -1393,6 +1403,7 @@ export async function redoTask( req, res ) {
|
|
|
1393
1403
|
}
|
|
1394
1404
|
let data = { ...question[sectionIndex].questions[req.body.payload.qno - 1], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
|
|
1395
1405
|
let userAnswer = data.userAnswer;
|
|
1406
|
+
console.log( userAnswer );
|
|
1396
1407
|
question[sectionIndex].questions[req.body.payload.qno - 1] = data;
|
|
1397
1408
|
question[sectionIndex].questions[req.body.payload.qno - 1].remarks = '';
|
|
1398
1409
|
question[sectionIndex].questions[req.body.payload.qno - 1].userAnswer = [];
|
|
@@ -1401,6 +1412,7 @@ export async function redoTask( req, res ) {
|
|
|
1401
1412
|
checklistStatus: 'open',
|
|
1402
1413
|
redoStatus: true,
|
|
1403
1414
|
questionAnswers: question,
|
|
1415
|
+
...( dayjs.utc( taskDetails.scheduleEndTime_iso ).format( 'YYYY-MM-DD' ) == dayjs().format( 'YYYY-MM-DD' ) ) ? { scheduleEndTime_iso: dayjs.utc().endOf( 'day' ) } :{},
|
|
1404
1416
|
};
|
|
1405
1417
|
|
|
1406
1418
|
let response = await taskProcessedService.updateOne( { _id: req.body.payload._id }, updateData );
|
|
@@ -1425,6 +1437,7 @@ export async function redoTask( req, res ) {
|
|
|
1425
1437
|
submitedBy: taskDetails.userName,
|
|
1426
1438
|
submitTime: taskDetails.submitTime,
|
|
1427
1439
|
};
|
|
1440
|
+
console.log( data );
|
|
1428
1441
|
await checklistLogs.create( data );
|
|
1429
1442
|
const requestOptions = {
|
|
1430
1443
|
method: 'POST',
|
|
@@ -1617,7 +1630,7 @@ export async function approvalstatus( req, res ) {
|
|
|
1617
1630
|
if ( filterApprover.length === 0 ) {
|
|
1618
1631
|
if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
|
|
1619
1632
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1620
|
-
let resultData = await LamdaServiceCall( url.
|
|
1633
|
+
let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
|
|
1621
1634
|
if ( resultData ) {
|
|
1622
1635
|
console.log( resultData.status_code );
|
|
1623
1636
|
if ( resultData.status_code == '200' ) {
|
|
@@ -1631,7 +1644,7 @@ export async function approvalstatus( req, res ) {
|
|
|
1631
1644
|
|
|
1632
1645
|
|
|
1633
1646
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
1634
|
-
let resultData = await LamdaServiceCall( url.
|
|
1647
|
+
let resultData = await LamdaServiceCall( url.approvalstatustask, req.body );
|
|
1635
1648
|
console.log( resultData );
|
|
1636
1649
|
if ( resultData ) {
|
|
1637
1650
|
if ( resultData.status_code == '200' ) {
|
|
@@ -1881,7 +1894,7 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
1881
1894
|
|
|
1882
1895
|
let dupDetails = { ...checkDetails._doc };
|
|
1883
1896
|
let name = `^${dupDetails.checkListName.split( '(' )[0]}\\(.*\\)$`;
|
|
1884
|
-
let checkListNameDetails = await taskService.find( { checkListName: { $regex: name }, client_id: req.query.clientId
|
|
1897
|
+
let checkListNameDetails = await taskService.find( { checkListName: { $regex: name }, client_id: req.query.clientId } );
|
|
1885
1898
|
if ( checkListNameDetails.length ) {
|
|
1886
1899
|
let nameLength = checkListNameDetails.length + 1;
|
|
1887
1900
|
dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength +')';
|
|
@@ -107,8 +107,8 @@ export const taskTableV1 = async ( req, res ) => {
|
|
|
107
107
|
let offset = parseInt( req.body.offset - 1 ) || 0;
|
|
108
108
|
let page = offset * limit;
|
|
109
109
|
let query = [];
|
|
110
|
-
let fromDate = new Date(
|
|
111
|
-
let toDate = new Date(
|
|
110
|
+
let fromDate = new Date( req.body.fromDate );
|
|
111
|
+
let toDate = new Date( req.body.toDate );
|
|
112
112
|
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
113
113
|
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
114
114
|
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
@@ -238,7 +238,7 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
238
238
|
if ( requestData.checklistStatus == 'redo' ) {
|
|
239
239
|
findAndQuery.push(
|
|
240
240
|
{ redoStatus: true },
|
|
241
|
-
|
|
241
|
+
);
|
|
242
242
|
} else {
|
|
243
243
|
findAndQuery.push( { checklistStatus: requestData.checklistStatus } );
|
|
244
244
|
}
|
|
@@ -282,6 +282,9 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
282
282
|
scheduleEndTime_iso: { $first: '$scheduleEndTime_iso' },
|
|
283
283
|
processedchecklistId: { $first: '$_id' },
|
|
284
284
|
redoStatus: { $first: '$redoStatus' },
|
|
285
|
+
priorityType: { $first: '$priorityType' },
|
|
286
|
+
allowedStoreLocation: { $first: '$allowedStoreLocation' },
|
|
287
|
+
restrictAttendance: { $first: '$restrictAttendance' },
|
|
285
288
|
},
|
|
286
289
|
},
|
|
287
290
|
);
|
|
@@ -307,6 +310,9 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
307
310
|
scheduleEndTime_iso: 1,
|
|
308
311
|
processedchecklistId: 1,
|
|
309
312
|
redoStatus: 1,
|
|
313
|
+
priorityType: 1,
|
|
314
|
+
allowedStoreLocation: 1,
|
|
315
|
+
restrictAttendance: 1,
|
|
310
316
|
},
|
|
311
317
|
} );
|
|
312
318
|
|
|
@@ -348,6 +354,9 @@ export const taskInfoTableV1 = async ( req, res ) => {
|
|
|
348
354
|
scheduleEndTime_iso: 1,
|
|
349
355
|
processedchecklistId: 1,
|
|
350
356
|
redoStatus: 1,
|
|
357
|
+
priorityType: 1,
|
|
358
|
+
allowedStoreLocation: 1,
|
|
359
|
+
restrictAttendance: 1,
|
|
351
360
|
},
|
|
352
361
|
} );
|
|
353
362
|
|
|
@@ -722,13 +731,13 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
722
731
|
findQuery.push(
|
|
723
732
|
{
|
|
724
733
|
$group: {
|
|
725
|
-
_id: '$
|
|
734
|
+
_id: '$_id',
|
|
726
735
|
checkListName: { $first: '$checkListName' },
|
|
727
736
|
checkListType: { $first: '$checkListType' },
|
|
728
737
|
createdByName: { $first: '$createdByName' },
|
|
729
738
|
storeCount: { $first: '$storeCount' },
|
|
730
|
-
scheduleEndTimeISO: { $first: '$
|
|
731
|
-
submitTime_string: { $first: '$submitTime_string' },
|
|
739
|
+
scheduleEndTimeISO: { $first: '$scheduleEndTimeISO' },
|
|
740
|
+
// submitTime_string: { $first: '$submitTime_string' },
|
|
732
741
|
},
|
|
733
742
|
},
|
|
734
743
|
);
|
|
@@ -742,7 +751,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
742
751
|
createdByName: 1,
|
|
743
752
|
storeCount: 1,
|
|
744
753
|
scheduleEndTimeISO: 1,
|
|
745
|
-
submitTime_string: 1,
|
|
754
|
+
// submitTime_string: 1,
|
|
746
755
|
},
|
|
747
756
|
} );
|
|
748
757
|
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
@@ -750,7 +759,7 @@ export const taskDropdownListV1 = async ( req, res ) => {
|
|
|
750
759
|
} else {
|
|
751
760
|
findQuery.push( { $sort: { ['checkListNameLowercase']: 1 } } );
|
|
752
761
|
}
|
|
753
|
-
let getChecklistData = await
|
|
762
|
+
let getChecklistData = await taskService.aggregate( findQuery );
|
|
754
763
|
if ( !getChecklistData.length ) {
|
|
755
764
|
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
756
765
|
}
|
|
@@ -1033,14 +1042,14 @@ export async function taskDetails( req, res ) {
|
|
|
1033
1042
|
const exportResult = [];
|
|
1034
1043
|
for ( let task of taskDetails[0].data ) {
|
|
1035
1044
|
exportResult.push( {
|
|
1036
|
-
'Task Name': task?.checkListName ||'',
|
|
1045
|
+
'Task Name': task?.checkListName ||'--',
|
|
1037
1046
|
'Created by': task?.createdByName ||'--',
|
|
1038
|
-
'Created On': dayjs.utc( task?.publishDate ).format( 'DD MMM, YYYY' ) || '',
|
|
1047
|
+
'Created On': dayjs.utc( task?.publishDate ).format( 'DD MMM, YYYY' ) || '--',
|
|
1039
1048
|
'Priority': task?.priorityType || '--',
|
|
1040
1049
|
'Assigned To': task?.storeCount ||'--',
|
|
1041
1050
|
'Submitted': task?.submitCount ||'--',
|
|
1042
1051
|
'Redo': task?.redoCount ||'--',
|
|
1043
|
-
'Due on': dayjs.utc( task?.scheduleEndTime_iso ).format( 'DD MMM, YYYY' ) || '',
|
|
1052
|
+
'Due on': dayjs.utc( task?.scheduleEndTime_iso ).format( 'DD MMM, YYYY' ) || '--',
|
|
1044
1053
|
} );
|
|
1045
1054
|
}
|
|
1046
1055
|
await download( exportResult, res );
|