tango-app-api-trax 3.2.1 → 3.3.1-beta-2
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 +2 -2
- package/src/controllers/internalTrax.controller.js +67 -0
- package/src/controllers/mobileTrax.controller.js +90 -51
- package/src/controllers/trax.controller.js +92 -17
- package/src/dtos/validation.dtos.js +9 -0
- package/src/hbs/login-otp.hbs +943 -943
- package/src/routes/internalTraxApi.router.js +2 -1
- package/src/routes/mobileTrax.routes.js +2 -1
- package/src/routes/trax.routes.js +5 -2
- package/src/services/teams.service.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1-beta-2",
|
|
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.2.
|
|
29
|
+
"tango-api-schema": "^2.2.24",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.50",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -1421,3 +1421,70 @@ export async function taskPushNotification( req, res ) {
|
|
|
1421
1421
|
return res.sendError( e, 500 );
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
|
+
|
|
1425
|
+
export async function internalSendPushNotification( req, res ) {
|
|
1426
|
+
try {
|
|
1427
|
+
let requestHeader = req.headers;
|
|
1428
|
+
if ( !( requestHeader.clientid ) ) {
|
|
1429
|
+
return res.sendError( 'clientid is Required', 400 );
|
|
1430
|
+
}
|
|
1431
|
+
if ( !( requestHeader.email || requestHeader.storeid ) ) {
|
|
1432
|
+
return res.sendError( 'Email or Storeid is Required', 400 );
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
let requestData = req.body;
|
|
1436
|
+
if ( !requestData.title ) {
|
|
1437
|
+
return res.sendError( 'Title is Required', 400 );
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
if ( !requestData.description ) {
|
|
1441
|
+
return res.sendError( 'Description is Required', 400 );
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
let fcmToken;
|
|
1445
|
+
// fcmToken = 'dwm2tz9WfUq1jdz1H8hfSf:APA91bF9BhTsG9ZDnutQfseGueXk7FZ4RhB8v3G_xJOZhkiZz8vsw3SUWk5su8ZN37lx3-H50eouBKinbwg4zE_br6f483jUswA_44f1XG8k7Sok995f77M';
|
|
1446
|
+
if ( requestHeader.email && requestHeader.email !='' ) {
|
|
1447
|
+
fcmToken = await getUserToken( requestHeader.clientid, requestHeader.email );
|
|
1448
|
+
} else {
|
|
1449
|
+
let storeData = await storeService.findOne( { clientId: requestHeader.clientid, storeId: requestHeader.storeid }, { spocDetails: 1 } );
|
|
1450
|
+
if ( storeData && storeData.spocDetails.length > 0 && storeData.spocDetails[0].email ) {
|
|
1451
|
+
fcmToken = await getUserToken( storeData.spocDetails[0].email );
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
// console.log( 'fcmToken =>', fcmToken );
|
|
1455
|
+
if ( !fcmToken ) {
|
|
1456
|
+
// return res.sendError( 'Token not found', 400 );
|
|
1457
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1458
|
+
}
|
|
1459
|
+
let responseData = await sendPushNotification( requestData.title, requestData.description, fcmToken );
|
|
1460
|
+
// console.log( 'responseData =>', responseData );
|
|
1461
|
+
if ( responseData ) {
|
|
1462
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1463
|
+
} else {
|
|
1464
|
+
// return res.sendError( 'Token not found', 400 );
|
|
1465
|
+
return res.sendSuccess( 'Notification Send Successfully' );
|
|
1466
|
+
}
|
|
1467
|
+
} catch ( e ) {
|
|
1468
|
+
logger.error( { error: e, function: 'internalSendPushNotification' } );
|
|
1469
|
+
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
1470
|
+
else res.sendError( e, 500 );
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
async function getUserToken( clientId, userEmail ) {
|
|
1475
|
+
try {
|
|
1476
|
+
if ( clientId && clientId !='' && userEmail && userEmail !='' ) {
|
|
1477
|
+
let userData = await userService.findOne( { clientId: clientId, email: userEmail }, { fcmToken: 1 } );
|
|
1478
|
+
if ( userData && userData.fcmToken && userData.fcmToken !='' ) {
|
|
1479
|
+
return userData.fcmToken;
|
|
1480
|
+
} else {
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1483
|
+
} else {
|
|
1484
|
+
return false;
|
|
1485
|
+
}
|
|
1486
|
+
} catch ( e ) {
|
|
1487
|
+
logger.error( { error: e, function: 'getUserToken' } );
|
|
1488
|
+
return false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
@@ -220,30 +220,35 @@ export async function startChecklist( req, res ) {
|
|
|
220
220
|
|
|
221
221
|
let getchecklist = getupdatedchecklist;
|
|
222
222
|
let questions = [];
|
|
223
|
-
function processQuestion( question, section, questions, nested=false ) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
223
|
+
// function processQuestion( question, section, questions, nested=false ) {
|
|
224
|
+
// let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
225
|
+
// if ( findExists && nested ) {
|
|
226
|
+
// let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
227
|
+
// questions.splice( findIndex, 1 );
|
|
228
|
+
// questions.push( question );
|
|
229
|
+
// }
|
|
230
|
+
// if ( !findExists ) {
|
|
231
|
+
// questions.push( question );
|
|
232
|
+
// for ( let answer of question.answers ) {
|
|
233
|
+
// if ( answer.showLinked && answer?.linkedQuestion != '' ) {
|
|
234
|
+
// let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
235
|
+
// if ( linkedQuestion ) {
|
|
236
|
+
// processQuestion( linkedQuestion, section, questions, true );
|
|
237
|
+
// }
|
|
238
|
+
// }
|
|
239
|
+
// }
|
|
240
|
+
// }
|
|
241
|
+
// }
|
|
242
242
|
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
243
243
|
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
244
244
|
questions = [];
|
|
245
245
|
for ( let question of section.questions ) {
|
|
246
|
-
|
|
246
|
+
if ( !question.linkType ) {
|
|
247
|
+
questions.push( question );
|
|
248
|
+
let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
|
|
249
|
+
let linkedQuestion = section.questions.filter( ( qn ) => linkedAnswer.has( qn.qno ) );
|
|
250
|
+
questions.push( ...linkedQuestion );
|
|
251
|
+
}
|
|
247
252
|
}
|
|
248
253
|
getchecklist[index].questionAnswers[secIndex].questions = questions;
|
|
249
254
|
}
|
|
@@ -1792,7 +1797,9 @@ export async function submitChecklist( req, res ) {
|
|
|
1792
1797
|
// createdAt: createdAtDate,
|
|
1793
1798
|
// };
|
|
1794
1799
|
// await detectionService.create( detectionData );
|
|
1795
|
-
|
|
1800
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1801
|
+
updateOpenSearch( req.user, requestData );
|
|
1802
|
+
}
|
|
1796
1803
|
|
|
1797
1804
|
return res.sendSuccess( 'Checklist Updated Successfully' );
|
|
1798
1805
|
} else {
|
|
@@ -1956,7 +1963,9 @@ export async function submitTask( req, res ) {
|
|
|
1956
1963
|
};
|
|
1957
1964
|
await checklistLogs.create( logInsertData );
|
|
1958
1965
|
|
|
1959
|
-
|
|
1966
|
+
if ( submittype == 'submit' ) {
|
|
1967
|
+
updateOpenSearchTask( user, requestData );
|
|
1968
|
+
}
|
|
1960
1969
|
|
|
1961
1970
|
return res.sendSuccess( 'Task Updated Successfully' );
|
|
1962
1971
|
} else {
|
|
@@ -2476,7 +2485,11 @@ export async function questionList( req, res ) {
|
|
|
2476
2485
|
if ( question.answerType == 'multiplechoicemultiple' ) {
|
|
2477
2486
|
let checkvalidation = null;
|
|
2478
2487
|
if ( answer.validationAnswer && answer.validationAnswer !='' ) {
|
|
2479
|
-
|
|
2488
|
+
if ( answer.validationType != 'Descriptive Answer' ) {
|
|
2489
|
+
checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
|
|
2490
|
+
} else {
|
|
2491
|
+
checkvalidation = answer.validationAnswer;
|
|
2492
|
+
}
|
|
2480
2493
|
}
|
|
2481
2494
|
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
2482
2495
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
@@ -2539,38 +2552,43 @@ export async function questionList( req, res ) {
|
|
|
2539
2552
|
}
|
|
2540
2553
|
|
|
2541
2554
|
let questions = [];
|
|
2542
|
-
function processQuestion( question, section, questions, nested=false ) {
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
}
|
|
2555
|
+
// function processQuestion( question, section, questions, nested=false ) {
|
|
2556
|
+
// let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
|
|
2557
|
+
// if ( findExists && nested ) {
|
|
2558
|
+
// // let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
|
|
2559
|
+
// // questions.splice( findIndex, 1 );
|
|
2560
|
+
// questions.push( question );
|
|
2561
|
+
// for ( let answer of question.answers ) {
|
|
2562
|
+
// if ( answer.showLinked && answer?.linkedQuestion != '' ) {
|
|
2563
|
+
// let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
2564
|
+
// if ( linkedQuestion ) {
|
|
2565
|
+
// processQuestion( linkedQuestion, section, questions, true );
|
|
2566
|
+
// }
|
|
2567
|
+
// }
|
|
2568
|
+
// }
|
|
2569
|
+
// }
|
|
2570
|
+
// if ( !findExists ) {
|
|
2571
|
+
// questions.push( question );
|
|
2572
|
+
// for ( let answer of question.answers ) {
|
|
2573
|
+
// if ( answer.showLinked && answer?.linkedQuestion != '' ) {
|
|
2574
|
+
// let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
2575
|
+
// if ( linkedQuestion ) {
|
|
2576
|
+
// processQuestion( linkedQuestion, section, questions, true );
|
|
2577
|
+
// }
|
|
2578
|
+
// }
|
|
2579
|
+
// }
|
|
2580
|
+
// }
|
|
2581
|
+
// }
|
|
2569
2582
|
for ( let [ index, data ] of getchecklist.entries() ) {
|
|
2570
2583
|
for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
|
|
2571
2584
|
questions = [];
|
|
2572
2585
|
for ( let question of section.questions ) {
|
|
2573
|
-
|
|
2586
|
+
if ( !question.linkType ) {
|
|
2587
|
+
questions.push( question );
|
|
2588
|
+
let linkedAnswer = new Set( question.answers.filter( ( ele ) => ele.showLinked ).flatMap( ( ele ) => ele.nestedQuestion ) );
|
|
2589
|
+
let linkedQuestion = section.questions.filter( ( qn ) => linkedAnswer.has( qn.qno ) );
|
|
2590
|
+
questions.push( ...linkedQuestion );
|
|
2591
|
+
}
|
|
2574
2592
|
}
|
|
2575
2593
|
getchecklist[index].questionAnswers[secIndex].questions = questions;
|
|
2576
2594
|
}
|
|
@@ -3282,3 +3300,24 @@ export async function checkVersion( req, res ) {
|
|
|
3282
3300
|
return res.sendError( e, 500 );
|
|
3283
3301
|
}
|
|
3284
3302
|
}
|
|
3303
|
+
|
|
3304
|
+
export async function clientConfig( req, res ) {
|
|
3305
|
+
try {
|
|
3306
|
+
let requestData = req.body;
|
|
3307
|
+
if ( requestData.clientId && requestData.clientId !='' ) {
|
|
3308
|
+
let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1 } );
|
|
3309
|
+
console.log( ' getClientData=>', getClientData );
|
|
3310
|
+
if ( getClientData ) {
|
|
3311
|
+
return res.sendSuccess( getClientData );
|
|
3312
|
+
} else {
|
|
3313
|
+
return res.sendError( 'Invalid clientId', 400 );
|
|
3314
|
+
}
|
|
3315
|
+
} else {
|
|
3316
|
+
return res.sendError( 'clientId is Required', 400 );
|
|
3317
|
+
}
|
|
3318
|
+
} catch ( e ) {
|
|
3319
|
+
console.log( 'e =>', e );
|
|
3320
|
+
logger.error( { error: e, function: 'clientConfig' } );
|
|
3321
|
+
return res.sendError( e, 500 );
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
@@ -21,6 +21,8 @@ import utc from 'dayjs/plugin/utc.js';
|
|
|
21
21
|
import isEqual from 'lodash/isEqual.js';
|
|
22
22
|
dayjs.extend( utc );
|
|
23
23
|
dayjs.extend( customParseFormat );
|
|
24
|
+
import * as clusterServices from '../services/cluster.service.js';
|
|
25
|
+
import * as teamsServices from '../services/teams.service.js';
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
export const checklist = async ( req, res ) => {
|
|
@@ -246,9 +248,13 @@ export const create = async ( req, res ) => {
|
|
|
246
248
|
}
|
|
247
249
|
if ( answer.showLinked ) {
|
|
248
250
|
if ( nestedIndex != -1 ) {
|
|
249
|
-
section.questions[qIdx].answers[nestedIndex].nestedQuestion.
|
|
251
|
+
if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
252
|
+
section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
|
|
253
|
+
}
|
|
250
254
|
} else {
|
|
251
|
-
section.questions[qIdx].answers[index].nestedQuestion.
|
|
255
|
+
if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
256
|
+
section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
|
|
257
|
+
}
|
|
252
258
|
}
|
|
253
259
|
let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
254
260
|
if ( nestedLinkedQuestion ) {
|
|
@@ -751,9 +757,13 @@ export const update = async ( req, res ) => {
|
|
|
751
757
|
}
|
|
752
758
|
if ( answer.showLinked ) {
|
|
753
759
|
if ( nestedIndex != -1 ) {
|
|
754
|
-
section.questions[qIdx].answers[nestedIndex].nestedQuestion.
|
|
760
|
+
if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
761
|
+
section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
|
|
762
|
+
}
|
|
755
763
|
} else {
|
|
756
|
-
section.questions[qIdx].answers[index].nestedQuestion.
|
|
764
|
+
if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
|
|
765
|
+
section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
|
|
766
|
+
}
|
|
757
767
|
}
|
|
758
768
|
let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
|
|
759
769
|
if ( nestedLinkedQuestion ) {
|
|
@@ -2177,18 +2187,17 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2177
2187
|
getsubmitDetails[0].date_iso = new Date( date );
|
|
2178
2188
|
getsubmitDetails[0].redoStatus = false;
|
|
2179
2189
|
getsubmitDetails[0].approvalStatus = false;
|
|
2180
|
-
} else {
|
|
2181
|
-
if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
2182
|
-
console.log( editSubmit );
|
|
2183
|
-
let user = {
|
|
2184
|
-
_id: getsubmitDetails[0].userId,
|
|
2185
|
-
clientId: getsubmitDetails[0].client_id,
|
|
2186
|
-
};
|
|
2187
|
-
updateOpenSearch( user, { processedcheckListId: getsubmitDetails[0]._id, date: getsubmitDetails[0].date_string } );
|
|
2188
|
-
}
|
|
2189
2190
|
}
|
|
2190
2191
|
let data = { ...getsubmitDetails[0]._doc };
|
|
2191
2192
|
await processedchecklist.updateOne( { _id: getsubmitDetails[0]._id }, data );
|
|
2193
|
+
if ( editSubmit && getsubmitDetails[0].checklistStatus == 'submit' ) {
|
|
2194
|
+
console.log( editSubmit );
|
|
2195
|
+
let user = {
|
|
2196
|
+
_id: getsubmitDetails[0].userId,
|
|
2197
|
+
clientId: getsubmitDetails[0].client_id,
|
|
2198
|
+
};
|
|
2199
|
+
updateOpenSearch( user, { processedcheckListId: getsubmitDetails[0]._id, date: getsubmitDetails[0].date_string } );
|
|
2200
|
+
}
|
|
2192
2201
|
}
|
|
2193
2202
|
if ( getsubmitDetails[0]?.checklistStatus == 'submit' ) {
|
|
2194
2203
|
userIdList.push( element4._id );
|
|
@@ -2237,15 +2246,29 @@ async function insertPCBulkV3( getCLconfig, checklistId, currentdate, updatedche
|
|
|
2237
2246
|
await processedchecklist.insertMany( submitUser );
|
|
2238
2247
|
}
|
|
2239
2248
|
} else {
|
|
2240
|
-
let
|
|
2249
|
+
let deleteInprogressQuery = {
|
|
2241
2250
|
date_string: insertdata.date_string,
|
|
2242
2251
|
date_iso: insertdata.date_iso,
|
|
2243
2252
|
client_id: insertdata.client_id,
|
|
2244
2253
|
checkListId: updatedchecklist._id,
|
|
2245
|
-
checklistStatus: { $nin: [ 'submit' ] },
|
|
2254
|
+
checklistStatus: { $nin: [ 'submit', 'inprogress' ] },
|
|
2255
|
+
redoStatus: false,
|
|
2246
2256
|
};
|
|
2247
|
-
await processedchecklist.deleteMany(
|
|
2248
|
-
|
|
2257
|
+
await processedchecklist.deleteMany( deleteInprogressQuery );
|
|
2258
|
+
deleteInprogressQuery.checklistStatus = 'inprogress';
|
|
2259
|
+
deleteInprogressQuery.redoStatus = false;
|
|
2260
|
+
let getInprogressData = await processedchecklist.find( deleteInprogressQuery, { userId: 1, store_id: 1 } );
|
|
2261
|
+
if ( getInprogressData ) {
|
|
2262
|
+
allQuestion = allQuestion.filter( ( item ) => {
|
|
2263
|
+
let inprogressData = getInprogressData.find( ( ele ) => ele.userId.toString() == item.userId.toString() && ele.store_id == item.store_id );
|
|
2264
|
+
if ( !inprogressData ) {
|
|
2265
|
+
return item;
|
|
2266
|
+
}
|
|
2267
|
+
} );
|
|
2268
|
+
}
|
|
2269
|
+
if ( allQuestion.length ) {
|
|
2270
|
+
await processedchecklist.insertMany( allQuestion );
|
|
2271
|
+
}
|
|
2249
2272
|
}
|
|
2250
2273
|
} else {
|
|
2251
2274
|
let unAssignedList = allQuestion.reduce( ( acc, item ) => {
|
|
@@ -2534,3 +2557,55 @@ export const preDefinedChecklist = async ( req, res ) => {
|
|
|
2534
2557
|
}
|
|
2535
2558
|
};
|
|
2536
2559
|
|
|
2560
|
+
export const selectAssign = async ( req, res ) => {
|
|
2561
|
+
try {
|
|
2562
|
+
let requestData = req.body;
|
|
2563
|
+
let resuldData;
|
|
2564
|
+
if ( requestData.coverage == 'store' ) {
|
|
2565
|
+
// //Select Store and cluster
|
|
2566
|
+
let storeQuery = [
|
|
2567
|
+
{ $match: { clientId: requestData.clientId } },
|
|
2568
|
+
{ $project: { 'storeName': 1, 'storeId': 1, 'type': 'store' } },
|
|
2569
|
+
];
|
|
2570
|
+
let clusterQuery = [
|
|
2571
|
+
{ $match: { clientId: requestData.clientId } },
|
|
2572
|
+
{ $project: { 'clusterName': 1, 'type': 'cluster' } },
|
|
2573
|
+
];
|
|
2574
|
+
|
|
2575
|
+
const [ getStores, getClusters ] = await Promise.all( [
|
|
2576
|
+
storeService.aggregate( storeQuery ),
|
|
2577
|
+
clusterServices.aggregateCluster( clusterQuery ),
|
|
2578
|
+
] );
|
|
2579
|
+
// console.log( 'getStores =>', getStores );
|
|
2580
|
+
// console.log( 'getClusters =>', getClusters );
|
|
2581
|
+
resuldData = [ ...getStores, ...getClusters ];
|
|
2582
|
+
console.log( 'resuldData =>', resuldData );
|
|
2583
|
+
} else if ( requestData.coverage == 'user' ) {
|
|
2584
|
+
// //Select User and Teams
|
|
2585
|
+
let userQuery = [
|
|
2586
|
+
{ $match: { clientId: requestData.clientId } },
|
|
2587
|
+
{ $project: { 'userEmail': 1, 'userName': 1, 'type': 'user' } },
|
|
2588
|
+
];
|
|
2589
|
+
// let getUsers = await userService.aggregate( userQuery );
|
|
2590
|
+
// console.log( 'getUsers =>', getUsers );
|
|
2591
|
+
let teamQuery = [
|
|
2592
|
+
{ $match: { clientId: requestData.clientId } },
|
|
2593
|
+
{ $project: { 'teamName': 1, 'type': 'team' } },
|
|
2594
|
+
];
|
|
2595
|
+
// let getTeams = await teamsServices.aggregateTeams( teamQuery );
|
|
2596
|
+
// console.log( 'getTeams =>', getTeams );
|
|
2597
|
+
const [ getUsers, getTeams ] = await Promise.all( [
|
|
2598
|
+
userService.aggregate( userQuery ),
|
|
2599
|
+
teamsServices.aggregateTeams( teamQuery ),
|
|
2600
|
+
] );
|
|
2601
|
+
resuldData = [ ...getUsers, ...getTeams ];
|
|
2602
|
+
console.log( 'resuldData =>', resuldData );
|
|
2603
|
+
}
|
|
2604
|
+
return res.sendSuccess( { 'totalCount': resuldData.length, 'data': resuldData } );
|
|
2605
|
+
} catch ( e ) {
|
|
2606
|
+
console.log( 'e =>', e );
|
|
2607
|
+
logger.error( 'selectAssign =>', e );
|
|
2608
|
+
return res.sendError( e, 500 );
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
|
|
@@ -144,4 +144,13 @@ export const startValidation = {
|
|
|
144
144
|
body: startSchema,
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
+
export const selectAssignSchema = joi.object( {
|
|
148
|
+
clientId: joi.string().required(),
|
|
149
|
+
coverage: joi.string().required(),
|
|
150
|
+
} );
|
|
151
|
+
|
|
152
|
+
export const selectAssign = {
|
|
153
|
+
body: selectAssignSchema,
|
|
154
|
+
};
|
|
155
|
+
|
|
147
156
|
|