tango-app-api-trax 1.0.0-alpha-task.130 → 1.0.0-alpha-task.132
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-trax",
|
|
3
|
-
"version": "1.0.0-alpha-task.
|
|
3
|
+
"version": "1.0.0-alpha-task.132",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.8.0",
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
|
-
"tango-api-schema": "^2.1.
|
|
29
|
+
"tango-api-schema": "^2.1.97",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.43-alpha.10",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -2,7 +2,10 @@ import { logger, signedUrl, sendMessageToQueue } from 'tango-app-api-middleware'
|
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import * as downloadService from '../services/download.services.js';
|
|
4
4
|
import * as processedchecklistService from '../services/processedchecklist.services.js';
|
|
5
|
+
import * as processedTaskService from '../services/processedTaskList.service.js';
|
|
6
|
+
import * as taskConfigService from '../services/taskConfig.service.js';
|
|
5
7
|
import * as checklistService from '../services/checklist.service.js';
|
|
8
|
+
// import * as processedTaskconfigService from '../services/processedTaskConfig.service.js';
|
|
6
9
|
import * as clientService from '../services/clients.services.js';
|
|
7
10
|
import * as storeService from '../services/store.service.js';
|
|
8
11
|
|
|
@@ -40,7 +43,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id !='' ) {
|
|
46
|
+
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
|
|
44
47
|
let getChecklistQuery = [];
|
|
45
48
|
getChecklistQuery.push( { $project: { sourceCheckList_id: 1, date_iso: 1, store_id: 1, checklistStatus: 1 } } );
|
|
46
49
|
getChecklistQuery.push( {
|
|
@@ -54,9 +57,12 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
54
57
|
},
|
|
55
58
|
} );
|
|
56
59
|
getChecklistQuery.push( { $count: 'totalCount' } );
|
|
57
|
-
let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
|
|
62
|
+
if ( requestData.insertType === 'task' ) {
|
|
63
|
+
getChecklistCount = await processedTaskService.aggregate( getChecklistQuery );
|
|
64
|
+
}
|
|
65
|
+
if ( getChecklistCount && getChecklistCount[0]?.totalCount && getChecklistCount[0].totalCount > 0 ) {
|
|
60
66
|
// console.log( 'if' );
|
|
61
67
|
// console.log( 'getChecklistCountgetChecklistCount[0].totalCount =>', getChecklistCount[0]?.totalCount );
|
|
62
68
|
} else {
|
|
@@ -65,7 +71,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
if ( requestData.fileType == 'pdf' ) {
|
|
68
|
-
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id !='' ) {
|
|
74
|
+
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
|
|
69
75
|
fileType = 'pdfzip';
|
|
70
76
|
}
|
|
71
77
|
if ( requestData?.checklistId && requestData?.checklistId.length > 1 ) {
|
|
@@ -76,7 +82,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
76
82
|
if ( requestData.checklistName != '' ) {
|
|
77
83
|
name = requestData.checklistName + '_' + dayjs( requestData.fromDate ).format( 'DD/MM/YYYY' );
|
|
78
84
|
if ( requestData?.toDate ) {
|
|
79
|
-
name = name + '-'+ dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
85
|
+
name = name + '-' + dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
80
86
|
}
|
|
81
87
|
let regexName = new RegExp( `^${name.split( '(' )[0]} \\(.*\\)$`, 'i' );
|
|
82
88
|
let type = requestData.fileType || 'pdfzip';
|
|
@@ -88,7 +94,7 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
88
94
|
name = requestData?.checklistName;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
name = name+'-'+requestData.fileType;
|
|
97
|
+
name = name + '-' + requestData.fileType;
|
|
92
98
|
let insertData = {
|
|
93
99
|
'date_string': requestData.fromDate || '',
|
|
94
100
|
'sourceCheckList_id': requestData?.sourceCheckList_id || '',
|
|
@@ -110,6 +116,9 @@ export const downloadInsert = async ( req, res ) => {
|
|
|
110
116
|
'downloadInsertFrom': requestData.downloadInsertFrom || '',
|
|
111
117
|
'answerType': requestData.answerType || '',
|
|
112
118
|
'searchValue': requestData.searchValue || '',
|
|
119
|
+
'insertType': requestData.insertType || '',
|
|
120
|
+
'viewRedo': requestData.viewRedo || false,
|
|
121
|
+
|
|
113
122
|
};
|
|
114
123
|
let resultData = await downloadService.insert( insertData );
|
|
115
124
|
if ( resultData ) {
|
|
@@ -151,10 +160,10 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
151
160
|
{ date_iso: { $lte: todate } },
|
|
152
161
|
{ checklistStatus: 'submit' },
|
|
153
162
|
);
|
|
154
|
-
if ( requestData.storeIds && requestData.storeIds.length >0 ) {
|
|
163
|
+
if ( requestData.storeIds && requestData.storeIds.length > 0 ) {
|
|
155
164
|
findAndQuery.push( { store_id: { $in: requestData.storeIds } } );
|
|
156
165
|
}
|
|
157
|
-
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id !='' ) {
|
|
166
|
+
if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
|
|
158
167
|
findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) } );
|
|
159
168
|
}
|
|
160
169
|
if ( requestData.checklistId && requestData.checklistId.length > 0 ) {
|
|
@@ -175,11 +184,11 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
175
184
|
},
|
|
176
185
|
} );
|
|
177
186
|
let checklistDetails = await processedchecklistService.aggregate( findQuery );
|
|
178
|
-
if ( checklistDetails && checklistDetails.length >0 ) {
|
|
187
|
+
if ( checklistDetails && checklistDetails.length > 0 ) {
|
|
179
188
|
let name;
|
|
180
189
|
let fileType = requestData?.fileType || 'pdfzip';
|
|
181
190
|
if ( requestData.fileType == 'pdf' ) {
|
|
182
|
-
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id !='' ) {
|
|
191
|
+
if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
|
|
183
192
|
fileType = 'pdfzip';
|
|
184
193
|
}
|
|
185
194
|
if ( requestData?.checklistId && requestData?.checklistId.length > 1 ) {
|
|
@@ -191,7 +200,7 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
191
200
|
if ( requestData.checklistName != '' ) {
|
|
192
201
|
name = requestData.checklistName + '_' + dayjs( requestData.fromDate ).format( 'DD/MM/YYYY' );
|
|
193
202
|
if ( requestData?.toDate ) {
|
|
194
|
-
name = name + '-'+ dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
203
|
+
name = name + '-' + dayjs( requestData?.toDate ).format( 'DD/MM/YYYY' );
|
|
195
204
|
}
|
|
196
205
|
let regexName = new RegExp( `^${name.split( '(' )[0]} \\(.*\\)$`, 'i' );
|
|
197
206
|
let type = requestData.fileType || 'pdfzip';
|
|
@@ -203,7 +212,7 @@ export const downloadInsertOld = async ( req, res ) => {
|
|
|
203
212
|
name = requestData?.checklistName;
|
|
204
213
|
}
|
|
205
214
|
|
|
206
|
-
name = name+'-'+requestData.fileType;
|
|
215
|
+
name = name + '-' + requestData.fileType;
|
|
207
216
|
let insertData = {
|
|
208
217
|
'date_string': requestData.fromDate || '',
|
|
209
218
|
'sourceCheckList_id': requestData?.sourceCheckList_id || '',
|
|
@@ -296,7 +305,7 @@ export const downloadList = async ( req, res ) => {
|
|
|
296
305
|
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
297
306
|
}
|
|
298
307
|
|
|
299
|
-
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
308
|
+
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy != '' ) {
|
|
300
309
|
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
301
310
|
} else {
|
|
302
311
|
findQuery.push( { $sort: { ['_id']: -1 } } );
|
|
@@ -307,8 +316,8 @@ export const downloadList = async ( req, res ) => {
|
|
|
307
316
|
findQuery.push( { $skip: skip }, { $limit: limit } );
|
|
308
317
|
let getDownlaodData = await downloadService.aggregate( findQuery );
|
|
309
318
|
let bucket = JSON.parse( process.env.BUCKET );
|
|
310
|
-
for ( let i=0; i<getDownlaodData.length; i++ ) {
|
|
311
|
-
if ( getDownlaodData[i].url && getDownlaodData[i].url !='' ) {
|
|
319
|
+
for ( let i = 0; i < getDownlaodData.length; i++ ) {
|
|
320
|
+
if ( getDownlaodData[i].url && getDownlaodData[i].url != '' ) {
|
|
312
321
|
let inputData1 = {
|
|
313
322
|
Bucket: bucket.sop,
|
|
314
323
|
file_path: getDownlaodData[i].url,
|
|
@@ -367,12 +376,11 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
367
376
|
brandLogo: '',
|
|
368
377
|
checkListDescription: '',
|
|
369
378
|
};
|
|
370
|
-
|
|
371
379
|
if ( getzipdata ) {
|
|
372
380
|
let getClientData = await clientService.findOne( { clientId: getzipdata.client_id } );
|
|
373
381
|
if ( getClientData ) {
|
|
374
382
|
brandInfo.clientName = getClientData.clientName;
|
|
375
|
-
brandInfo.brandLogo = getzipdata.client_id+'/logo/'+getClientData.profileDetails.logo;
|
|
383
|
+
brandInfo.brandLogo = getzipdata.client_id + '/logo/' + getClientData.profileDetails.logo;
|
|
376
384
|
}
|
|
377
385
|
|
|
378
386
|
// if ( getzipdata.fileType == 'zipfiles' ) {
|
|
@@ -387,7 +395,12 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
387
395
|
|
|
388
396
|
if ( getzipdata.sourceCheckList_id && getzipdata.sourceCheckList_id != '' ) {
|
|
389
397
|
let getChecklistDescription = await checklistService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
390
|
-
|
|
398
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
399
|
+
let getChecklistDescription = await taskConfigService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
400
|
+
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
401
|
+
} else {
|
|
402
|
+
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
403
|
+
}
|
|
391
404
|
|
|
392
405
|
resultData.brandInfo = brandInfo;
|
|
393
406
|
if ( getzipdata.sourceCheckList_id && getzipdata.sourceCheckList_id != '' ) {
|
|
@@ -404,13 +417,21 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
404
417
|
resultData.viewFlag = getzipdata.viewFlag;
|
|
405
418
|
resultData.previewType = getzipdata.previewType || '';
|
|
406
419
|
resultData.answerType = getzipdata.answerType || '';
|
|
420
|
+
resultData.insertType = getzipdata.insertType;
|
|
407
421
|
return res.sendSuccess( resultData );
|
|
408
422
|
} else {
|
|
409
423
|
let getchecklistsQuery = {};
|
|
410
424
|
getchecklistsQuery._id = new mongoose.Types.ObjectId( getzipdata.checklistIdList[0] );
|
|
411
425
|
let getchecklistsData = await processedchecklistService.findOne( getchecklistsQuery, { _id: 1, sourceCheckList_id: 1 } );
|
|
426
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
427
|
+
getchecklistsData = await processedTaskService.findOne( getchecklistsQuery, { _id: 1, sourceCheckList_id: 1 } );
|
|
428
|
+
}
|
|
429
|
+
|
|
412
430
|
if ( getchecklistsData ) {
|
|
413
431
|
let getChecklistDescription = await checklistService.findOne( { _id: getchecklistsData.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
432
|
+
if ( getzipdata.insertType == 'task' ) {
|
|
433
|
+
getChecklistDescription = await taskConfigService.findOne( { _id: getzipdata.sourceCheckList_id }, { checkListName: 1, checkListDescription: 1 } );
|
|
434
|
+
}
|
|
414
435
|
brandInfo.checkListDescription = getChecklistDescription.checkListDescription || '';
|
|
415
436
|
}
|
|
416
437
|
|
|
@@ -418,6 +439,7 @@ export const getChecklistFromZipId = async ( req, res ) => {
|
|
|
418
439
|
resultData.checklistIds = getzipdata.checklistIdList;
|
|
419
440
|
resultData.fileType = getzipdata.fileType;
|
|
420
441
|
resultData.questions = getzipdata.questions;
|
|
442
|
+
resultData.insertType = getzipdata.insertType;
|
|
421
443
|
return res.sendSuccess( resultData );
|
|
422
444
|
}
|
|
423
445
|
} else {
|
|
@@ -459,12 +481,14 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
|
459
481
|
];
|
|
460
482
|
|
|
461
483
|
let getchecklistsData = await processedchecklistService.aggregate( query );
|
|
462
|
-
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
if ( getchecklistsData && getchecklistsData.length > 0 ) {
|
|
463
487
|
let getbrand = await clientService.findOne( { clientId: getchecklistsData[0].client_id }, { clientName: 1 } );
|
|
464
488
|
let brandInfo = {};
|
|
465
489
|
if ( getbrand ) {
|
|
466
490
|
brandInfo.clientName = getbrand.clientName;
|
|
467
|
-
brandInfo.brandLogo = getchecklistsData[0].client_id+'/logo/brandLogo.png';
|
|
491
|
+
brandInfo.brandLogo = getchecklistsData[0].client_id + '/logo/brandLogo.png';
|
|
468
492
|
}
|
|
469
493
|
|
|
470
494
|
let getstore = await storeService.findOne( { id: getchecklistsData[0].store_id }, { storeProfile: 1 } );
|
|
@@ -472,7 +496,7 @@ export const getPDFCSVChecklistDetails = async ( req, res ) => {
|
|
|
472
496
|
getchecklistsData[0].city = getstore?.storeProfile?.city || '--';
|
|
473
497
|
getchecklistsData[0].state = getstore?.storeProfile?.state || '--';
|
|
474
498
|
let questions = [];
|
|
475
|
-
function processQuestion( question, section, questions, nested=false ) {
|
|
499
|
+
function processQuestion( question, section, questions, nested = false ) {
|
|
476
500
|
let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
477
501
|
if ( findExists && nested ) {
|
|
478
502
|
let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
@@ -433,14 +433,19 @@ export async function getLogs( req, res ) {
|
|
|
433
433
|
|
|
434
434
|
export async function approvalstatus( req, res ) {
|
|
435
435
|
try {
|
|
436
|
-
let Approver = await ApproverModel.
|
|
437
|
-
if (
|
|
436
|
+
let Approver = await ApproverModel.find( { checkListId: req.body.checklistId } );
|
|
437
|
+
if ( Approver.length === 0 ) {
|
|
438
|
+
return res.sendError( 'No Content', 204 );
|
|
439
|
+
}
|
|
440
|
+
let filterApprover = Approver.filter( ( data ) => data.userEmail=== req.user.email );
|
|
441
|
+
if ( filterApprover.length === 0 ) {
|
|
438
442
|
return res.sendError( 'No Content', 204 );
|
|
439
443
|
}
|
|
440
444
|
|
|
441
445
|
|
|
442
446
|
let url = JSON.parse( process.env.LAMBDAURL );
|
|
443
447
|
let resultData = await LamdaServiceCall( url.approvalstatus, req.body );
|
|
448
|
+
console.log( resultData );
|
|
444
449
|
if ( resultData ) {
|
|
445
450
|
if ( resultData.status_code == '200' ) {
|
|
446
451
|
return res.sendSuccess( resultData );
|
|
@@ -48,7 +48,7 @@ export async function storeList( req, res ) {
|
|
|
48
48
|
|
|
49
49
|
return res.sendSuccess( storeStatus );
|
|
50
50
|
} catch ( e ) {
|
|
51
|
-
logger.error( { function: storeList, error: e } );
|
|
51
|
+
logger.error( { function: 'storeList', error: e, body: req.body } );
|
|
52
52
|
return res.sendError( e, 500 );
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -82,7 +82,7 @@ export async function storeListv1( req, res ) {
|
|
|
82
82
|
|
|
83
83
|
return res.sendSuccess( storeStatus );
|
|
84
84
|
} catch ( e ) {
|
|
85
|
-
logger.error( { function: 'storeListv1', error: e } );
|
|
85
|
+
logger.error( { function: 'storeListv1', error: e, body: req.body } );
|
|
86
86
|
return res.sendError( e, 500 );
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -242,7 +242,7 @@ export async function startChecklist( req, res ) {
|
|
|
242
242
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
243
243
|
}
|
|
244
244
|
} catch ( e ) {
|
|
245
|
-
logger.error( { function: 'startChecklist', error: e } );
|
|
245
|
+
logger.error( { function: 'startChecklist', error: e, body: req.body } );
|
|
246
246
|
return res.sendError( e, 500 );
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -386,7 +386,7 @@ export async function startTask( req, res ) {
|
|
|
386
386
|
|
|
387
387
|
return res.sendSuccess( getUpdatedTask );
|
|
388
388
|
} catch ( error ) {
|
|
389
|
-
logger.error( { function: 'startTask', error } );
|
|
389
|
+
logger.error( { function: 'startTask', error, body: req.body } );
|
|
390
390
|
return res.sendError( error, 500 );
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -422,7 +422,7 @@ export async function sopMobilechecklistValidater( req, res, next ) {
|
|
|
422
422
|
next();
|
|
423
423
|
}
|
|
424
424
|
} catch ( error ) {
|
|
425
|
-
logger.error( { function: 'sopMobilechecklistValidater', error: error } );
|
|
425
|
+
logger.error( { function: 'sopMobilechecklistValidater', error: error, body: req.body } );
|
|
426
426
|
return res.sendError( error );
|
|
427
427
|
}
|
|
428
428
|
};
|
|
@@ -463,7 +463,7 @@ export async function sopMobilechecklistQuestionValidator( req, res, next ) {
|
|
|
463
463
|
next();
|
|
464
464
|
}
|
|
465
465
|
} catch ( e ) {
|
|
466
|
-
logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e } );
|
|
466
|
+
logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
|
|
467
467
|
return res.sendError( e, 500 );
|
|
468
468
|
}
|
|
469
469
|
};
|
|
@@ -504,7 +504,7 @@ export async function sopMobileTaskQuestionValidator( req, res, next ) {
|
|
|
504
504
|
next();
|
|
505
505
|
}
|
|
506
506
|
} catch ( e ) {
|
|
507
|
-
logger.error( { function: 'sopMobileTaskQuestionValidator', error: e } );
|
|
507
|
+
logger.error( { function: 'sopMobileTaskQuestionValidator', error: e, body: req.body } );
|
|
508
508
|
return res.sendError( e, 500 );
|
|
509
509
|
}
|
|
510
510
|
};
|
|
@@ -789,7 +789,7 @@ export async function sopMobilechecklistMultiSectionFormatter( req, res, next )
|
|
|
789
789
|
requestData.questionAnswers = sectionFormat;
|
|
790
790
|
next();
|
|
791
791
|
} catch ( error ) {
|
|
792
|
-
logger.error( { function: '
|
|
792
|
+
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
793
793
|
return res.sendError( error, 500 );
|
|
794
794
|
}
|
|
795
795
|
};
|
|
@@ -1064,7 +1064,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1064
1064
|
requestData.questionAnswers = sectionFormat;
|
|
1065
1065
|
next();
|
|
1066
1066
|
} catch ( error ) {
|
|
1067
|
-
logger.error( { function: '
|
|
1067
|
+
logger.error( { function: 'sopMobileTaskMultiSectionFormatter', error: error, body: req.body } );
|
|
1068
1068
|
return res.sendError( error, 500 );
|
|
1069
1069
|
}
|
|
1070
1070
|
};
|
|
@@ -1085,7 +1085,7 @@ function QuestionFlag( req, res ) {
|
|
|
1085
1085
|
} );
|
|
1086
1086
|
return flagCount;
|
|
1087
1087
|
} catch ( error ) {
|
|
1088
|
-
logger.error( { function: 'QuestionFlag
|
|
1088
|
+
logger.error( { function: 'QuestionFlag', error: error, body: req.body } );
|
|
1089
1089
|
let msg = error.error ? error.error : error;
|
|
1090
1090
|
return res.sendError( msg, 500 );
|
|
1091
1091
|
}
|
|
@@ -1220,7 +1220,7 @@ export async function submitChecklist( req, res ) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
}
|
|
1222
1222
|
} catch ( e ) {
|
|
1223
|
-
logger.error( { function: 'submitChecklist', error: e } );
|
|
1223
|
+
logger.error( { function: 'submitChecklist', error: e, body: req.body } );
|
|
1224
1224
|
return res.sendError( e, 500 );
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
@@ -1323,7 +1323,7 @@ export async function submitTask( req, res ) {
|
|
|
1323
1323
|
return res.sendError( 'Something went wrong. Please try again', 500 );
|
|
1324
1324
|
}
|
|
1325
1325
|
} catch ( error ) {
|
|
1326
|
-
logger.error( { function: 'submitTask', error } );
|
|
1326
|
+
logger.error( { function: 'submitTask', error, body: req.body } );
|
|
1327
1327
|
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
@@ -1501,7 +1501,7 @@ export async function dashboard( req, res ) {
|
|
|
1501
1501
|
|
|
1502
1502
|
return res.sendSuccess( resultData );
|
|
1503
1503
|
} catch ( e ) {
|
|
1504
|
-
logger.error( { function: '
|
|
1504
|
+
logger.error( { function: 'dashboard', error: e, body: req.body } );
|
|
1505
1505
|
return res.sendError( e, 500 );
|
|
1506
1506
|
}
|
|
1507
1507
|
}
|
|
@@ -1575,7 +1575,7 @@ export async function dashboardv1( req, res ) {
|
|
|
1575
1575
|
|
|
1576
1576
|
return res.sendSuccess( totalResult );
|
|
1577
1577
|
} catch ( e ) {
|
|
1578
|
-
logger.error( { function: 'dashboardv1', error: e } );
|
|
1578
|
+
logger.error( { function: 'dashboardv1', error: e, body: req.body } );
|
|
1579
1579
|
return res.sendError( e, 500 );
|
|
1580
1580
|
}
|
|
1581
1581
|
}
|
|
@@ -1660,7 +1660,7 @@ export async function checklist( req, res ) {
|
|
|
1660
1660
|
|
|
1661
1661
|
return res.sendSuccess( { count: totalchecklist.length, data: totalchecklist } );
|
|
1662
1662
|
} catch ( e ) {
|
|
1663
|
-
logger.error( { function: 'checklist', error: e } );
|
|
1663
|
+
logger.error( { function: 'checklist', error: e, body: req.body } );
|
|
1664
1664
|
return res.sendError( e, 500 );
|
|
1665
1665
|
}
|
|
1666
1666
|
}
|
|
@@ -1755,7 +1755,7 @@ export async function checklistv1( req, res ) {
|
|
|
1755
1755
|
|
|
1756
1756
|
return res.sendSuccess( { count: totalData.length, data: totalData } );
|
|
1757
1757
|
} catch ( e ) {
|
|
1758
|
-
logger.error( { function: 'checklistv1', error: e } );
|
|
1758
|
+
logger.error( { function: 'checklistv1', error: e, body: req.body } );
|
|
1759
1759
|
return res.sendError( e, 500 );
|
|
1760
1760
|
}
|
|
1761
1761
|
}
|
|
@@ -1913,7 +1913,7 @@ export async function questionList( req, res ) {
|
|
|
1913
1913
|
return res.sendSuccess( getchecklist );
|
|
1914
1914
|
}
|
|
1915
1915
|
} catch ( e ) {
|
|
1916
|
-
logger.error( { function: 'questionList', error: e } );
|
|
1916
|
+
logger.error( { function: 'questionList', error: e, body: req.body } );
|
|
1917
1917
|
return res.sendError( e, 500 );
|
|
1918
1918
|
}
|
|
1919
1919
|
}
|
|
@@ -2037,7 +2037,7 @@ export async function taskQuestionList( req, res ) {
|
|
|
2037
2037
|
|
|
2038
2038
|
return res.sendSuccess( [ checklist ] );
|
|
2039
2039
|
} catch ( error ) {
|
|
2040
|
-
logger.error( { function: 'taskQuestionList', error } );
|
|
2040
|
+
logger.error( { function: 'taskQuestionList', error, body: req.body } );
|
|
2041
2041
|
return res.sendError( error.message || 'Internal Server Error', 500 );
|
|
2042
2042
|
}
|
|
2043
2043
|
}
|
|
@@ -2097,7 +2097,7 @@ export async function uploadAnswerImage( req, res ) {
|
|
|
2097
2097
|
return res.sendError( 'Please upload an image with key answerImage!', 400 );
|
|
2098
2098
|
}
|
|
2099
2099
|
} catch ( e ) {
|
|
2100
|
-
logger.error( { function: 'uploadAnswerImage', error: e } );
|
|
2100
|
+
logger.error( { function: 'uploadAnswerImage', error: e, body: req.body } );
|
|
2101
2101
|
return res.sendError( e, 500 );
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
@@ -2135,7 +2135,7 @@ export async function appVersion( req, res ) {
|
|
|
2135
2135
|
let response = await appService.aggregate( query );
|
|
2136
2136
|
return res.sendSuccess( { count: response[0].count.length ? response[0].count[0].count : 0, data: response[0].data } );
|
|
2137
2137
|
} catch ( e ) {
|
|
2138
|
-
logger.error( { function: 'appVersion', error: e } );
|
|
2138
|
+
logger.error( { function: 'appVersion', error: e, body: req.body } );
|
|
2139
2139
|
return res.sendError( e, 500 );
|
|
2140
2140
|
}
|
|
2141
2141
|
}
|
|
@@ -2162,7 +2162,7 @@ export async function updateappVersion( req, res ) {
|
|
|
2162
2162
|
return res.sendError( 'Something went wrong please try again', 500 );
|
|
2163
2163
|
}
|
|
2164
2164
|
} catch ( error ) {
|
|
2165
|
-
logger.error( { function: '
|
|
2165
|
+
logger.error( { function: 'updateappVersion', error: error, body: req.body } );
|
|
2166
2166
|
if ( error.name === 'ValidationError' ) return res.sendError( error, 400 );
|
|
2167
2167
|
else return res.sendError( error, 500 );
|
|
2168
2168
|
}
|
|
@@ -2221,7 +2221,7 @@ export async function login( req, res ) {
|
|
|
2221
2221
|
return res.sendSuccess( { result: token } );
|
|
2222
2222
|
}
|
|
2223
2223
|
} catch ( e ) {
|
|
2224
|
-
logger.error( { function: 'login', error: e } );
|
|
2224
|
+
logger.error( { function: 'login', error: e, body: req.body } );
|
|
2225
2225
|
return res.sendError( e, 500 );
|
|
2226
2226
|
}
|
|
2227
2227
|
}
|
|
@@ -2238,7 +2238,7 @@ export const sendSignInOtpEmail = async ( emailVars ) => {
|
|
|
2238
2238
|
const result = await sendEmailWithSES( emailVars.email, subject, html, attachments, ses.adminEmail );
|
|
2239
2239
|
return result;
|
|
2240
2240
|
} catch ( error ) {
|
|
2241
|
-
logger.error( { error: error, function: 'sendSignInOtpEmail' } );
|
|
2241
|
+
logger.error( { error: error, function: 'sendSignInOtpEmail', body: req.body } );
|
|
2242
2242
|
return error;
|
|
2243
2243
|
}
|
|
2244
2244
|
};
|
|
@@ -2300,7 +2300,7 @@ export async function location( req, res ) {
|
|
|
2300
2300
|
return res.sendError( 'Please include latitude and longitude!', 400 );
|
|
2301
2301
|
}
|
|
2302
2302
|
} catch ( e ) {
|
|
2303
|
-
logger.error( { error: e, function: 'location' } );
|
|
2303
|
+
logger.error( { error: e, function: 'location', body: req.body } );
|
|
2304
2304
|
return sendError( error, 500 );
|
|
2305
2305
|
}
|
|
2306
2306
|
}
|
|
@@ -2320,7 +2320,7 @@ export async function getStoreLocation( req, res, next ) {
|
|
|
2320
2320
|
return res.sendError( 'No store/Checklist assigned to the user!', 400 );
|
|
2321
2321
|
}
|
|
2322
2322
|
} catch ( error ) {
|
|
2323
|
-
logger.error( { function: '
|
|
2323
|
+
logger.error( { function: 'getStoreLocation', error: error, body: req.body } );
|
|
2324
2324
|
let msg = error.error ? error.error : error;
|
|
2325
2325
|
return res.sendError( msg, 500 );
|
|
2326
2326
|
}
|
|
@@ -20,6 +20,9 @@ export const validateDownloadInsertSchema = joi.object( {
|
|
|
20
20
|
userId: joi.string().optional().allow( '' ),
|
|
21
21
|
answerType: joi.string().optional().allow( '' ),
|
|
22
22
|
searchValue: joi.string().optional().allow( '' ),
|
|
23
|
+
viewRedo: joi.boolean().optional().allow( '' ),
|
|
24
|
+
insertType: joi.string().optional().allow( '' ),
|
|
25
|
+
|
|
23
26
|
} );
|
|
24
27
|
|
|
25
28
|
export const validateDownloadInsertParams = {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import model from 'tango-api-schema';
|
|
2
|
+
|
|
3
|
+
export const find = async ( query = {}, field={} ) => {
|
|
4
|
+
return model.taskConfigModel.find( query, field );
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const findOne = async ( query = {}, field={} ) => {
|
|
8
|
+
return model.taskConfigModel.findOne( query, field );
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const updateMany = async ( query = {}, record={} ) => {
|
|
12
|
+
return model.taskConfigModel.updateMany( query, { $set: record } );
|
|
13
|
+
};
|
|
14
|
+
export const updateOne = async ( query = {}, record={} ) => {
|
|
15
|
+
return model.taskConfigModel.updateOne( query, { $set: record } );
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const insertMany = async ( data = [] ) => {
|
|
19
|
+
return model.taskConfigModel.insertMany( data );
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const deleteMany = async ( query = [] ) => {
|
|
23
|
+
return model.taskConfigModel.deleteMany( query );
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const aggregate = async ( query = [] ) => {
|
|
27
|
+
return model.taskConfigModel.aggregate( query );
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const insert = async ( data = [] ) => {
|
|
31
|
+
return model.taskConfigModel.create( data );
|
|
32
|
+
};
|