tango-app-api-trax 3.3.1-beta-19 → 3.3.1-beta-21
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": "3.3.1-beta-
|
|
3
|
+
"version": "3.3.1-beta-21",
|
|
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.49",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.55",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -20,6 +20,8 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
20
20
|
import mongoose from 'mongoose';
|
|
21
21
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
22
22
|
import * as planoService from '../services/planogram.service.js';
|
|
23
|
+
import * as clusterServices from '../services/cluster.service.js';
|
|
24
|
+
import * as teamsServices from '../services/teams.service.js';
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
const ObjectId = mongoose.Types.ObjectId;
|
|
@@ -341,6 +343,152 @@ async function insertData( requestData ) {
|
|
|
341
343
|
} );
|
|
342
344
|
let allQuestion = await CLassign.aggregate( getquestionQuery );
|
|
343
345
|
if ( allQuestion.length ) {
|
|
346
|
+
let assignList = [];
|
|
347
|
+
if ( getCLconfig.coverage == 'store' ) {
|
|
348
|
+
let clusterList = allQuestion.filter( ( ele ) => ele?.clusterName ).map( ( item ) => item.assignId );
|
|
349
|
+
if ( clusterList.length ) {
|
|
350
|
+
let clusterDetails = await clusterServices.findcluster( { _id: { $in: clusterList } } );
|
|
351
|
+
if ( clusterDetails.length ) {
|
|
352
|
+
let idList = clusterDetails.flatMap( ( item ) => item.stores.map( ( ele ) => ele.store ) );
|
|
353
|
+
let getStoreDetails = await storeService.find( { _id: { $in: idList } } );
|
|
354
|
+
if ( getStoreDetails.length ) {
|
|
355
|
+
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
356
|
+
let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
|
|
357
|
+
if ( !userDetails ) {
|
|
358
|
+
let data = {
|
|
359
|
+
clientId: store.clientId,
|
|
360
|
+
userName: store.spocDetails?.[0]?.name,
|
|
361
|
+
mobileNumber: store.spocDetails?.[0]?.phone || '',
|
|
362
|
+
email: store.spocDetails[0].email,
|
|
363
|
+
password: '5dqFKAJj29PsV6P+kL+3Dw==',
|
|
364
|
+
role: 'user',
|
|
365
|
+
userType: 'client',
|
|
366
|
+
rolespermission: [
|
|
367
|
+
{
|
|
368
|
+
featureName: 'Global',
|
|
369
|
+
modules: [
|
|
370
|
+
{
|
|
371
|
+
name: 'Store',
|
|
372
|
+
isAdd: false,
|
|
373
|
+
isEdit: false,
|
|
374
|
+
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: 'User',
|
|
378
|
+
isAdd: false,
|
|
379
|
+
isEdit: false,
|
|
380
|
+
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'Camera',
|
|
384
|
+
isAdd: false,
|
|
385
|
+
isEdit: false,
|
|
386
|
+
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: 'Configuration',
|
|
390
|
+
isAdd: false,
|
|
391
|
+
isEdit: false,
|
|
392
|
+
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: 'Subscription',
|
|
396
|
+
isAdd: false,
|
|
397
|
+
isEdit: false,
|
|
398
|
+
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: 'Billing',
|
|
402
|
+
isAdd: false,
|
|
403
|
+
isEdit: false,
|
|
404
|
+
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
featurName: 'TangoEye',
|
|
410
|
+
modules: [
|
|
411
|
+
{
|
|
412
|
+
name: 'ZoneTag',
|
|
413
|
+
isAdd: false,
|
|
414
|
+
isEdit: false,
|
|
415
|
+
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
featurName: 'TangoTrax',
|
|
421
|
+
modules: [
|
|
422
|
+
{
|
|
423
|
+
name: 'checklist',
|
|
424
|
+
isAdd: false,
|
|
425
|
+
isEdit: false,
|
|
426
|
+
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: 'Task',
|
|
430
|
+
isAdd: false,
|
|
431
|
+
isEdit: false,
|
|
432
|
+
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
},
|
|
436
|
+
],
|
|
437
|
+
};
|
|
438
|
+
userDetails = await userService.create( data );
|
|
439
|
+
}
|
|
440
|
+
let data = {
|
|
441
|
+
store_id: store?.storeId,
|
|
442
|
+
storeName: store?.storeName,
|
|
443
|
+
userId: userDetails._id,
|
|
444
|
+
userName: userDetails.userName,
|
|
445
|
+
userEmail: userDetails.email,
|
|
446
|
+
userPhone: userDetails?.mobileNumber,
|
|
447
|
+
city: store?.storeProfile?.city,
|
|
448
|
+
country: store?.storeProfile?.country,
|
|
449
|
+
checkFlag: true,
|
|
450
|
+
checkListId: getCLconfig._id,
|
|
451
|
+
checkListName: getCLconfig.checkListName,
|
|
452
|
+
client_id: getCLconfig.client_id,
|
|
453
|
+
};
|
|
454
|
+
return data;
|
|
455
|
+
} ) );
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
allQuestion = allQuestion.filter( ( ele ) => !clusterList.includes( ele.assignId ) );
|
|
460
|
+
}
|
|
461
|
+
if ( getCLconfig.coverage == 'user' ) {
|
|
462
|
+
let teamsList = allQuestion.filter( ( ele ) => ele?.teamName ).map( ( item ) => item.assignId );
|
|
463
|
+
if ( teamsList.length ) {
|
|
464
|
+
let teamDetails = await teamsServices.findteams( { _id: { $in: teamsList } } );
|
|
465
|
+
if ( teamDetails.length ) {
|
|
466
|
+
let idList = teamDetails.flatMap( ( item ) => item.users.map( ( ele ) => ele.userId ) );
|
|
467
|
+
let getUserDetails = await userService.find( { _id: { $in: idList } } );
|
|
468
|
+
if ( getUserDetails.length ) {
|
|
469
|
+
assignList = getUserDetails.map( ( user ) => {
|
|
470
|
+
let data = {
|
|
471
|
+
store_id: '',
|
|
472
|
+
storeName: '',
|
|
473
|
+
userId: user._id,
|
|
474
|
+
userName: user.userName,
|
|
475
|
+
userEmail: user.email,
|
|
476
|
+
userPhone: user?.mobileNumber,
|
|
477
|
+
city: '',
|
|
478
|
+
country: '',
|
|
479
|
+
checkFlag: true,
|
|
480
|
+
checkListId: getCLconfig._id,
|
|
481
|
+
checkListName: getCLconfig.checkListName,
|
|
482
|
+
client_id: getCLconfig.client_id,
|
|
483
|
+
};
|
|
484
|
+
return data;
|
|
485
|
+
} );
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
allQuestion = allQuestion.filter( ( ele ) => !teamsList.includes( ele.assignId ) );
|
|
490
|
+
}
|
|
491
|
+
allQuestion = [ ...allQuestion, ...assignList ];
|
|
344
492
|
let userIdList = [];
|
|
345
493
|
for ( let element4 of allQuestion ) {
|
|
346
494
|
if ( getCLconfig.allowOnce && ![ 'onetime', 'daily' ].includes( getCLconfig.schedule ) ) {
|
|
@@ -28,8 +28,7 @@ export const overallFlagMetrics = async ( req, res ) => {
|
|
|
28
28
|
{ date_iso: { $gte: new Date( req.body.startDate ) } },
|
|
29
29
|
{ date_iso: { $lte: new Date( req.body.endDate ) } },
|
|
30
30
|
// { store_id: { $in: req.body.stores } },
|
|
31
|
-
{ userEmail: { $in: getUserEmails } },
|
|
32
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
31
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
33
32
|
],
|
|
34
33
|
},
|
|
35
34
|
},
|
|
@@ -277,8 +276,7 @@ export const checklistFlagsTable = async ( req, res ) => {
|
|
|
277
276
|
{ uniformDetectionFlag: { $gt: 0 } },
|
|
278
277
|
] },
|
|
279
278
|
// { store_id: { $in: req.body.stores } },
|
|
280
|
-
{ userEmail: { $in: getUserEmails } },
|
|
281
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
279
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
282
280
|
],
|
|
283
281
|
},
|
|
284
282
|
};
|
|
@@ -555,8 +553,7 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
555
553
|
{ aiStoreList: { $in: storeId } },
|
|
556
554
|
],
|
|
557
555
|
date_iso: { $gte: adjustedFromDate, $lte: adjustedToDate },
|
|
558
|
-
userEmail: { $in: getUserEmails },
|
|
559
|
-
$or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ],
|
|
556
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
560
557
|
},
|
|
561
558
|
},
|
|
562
559
|
{
|
|
@@ -698,8 +695,7 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
|
|
|
698
695
|
{ aiStoreList: { $in: requestData.storeId } },
|
|
699
696
|
],
|
|
700
697
|
date_iso: { $gte: fromDate, $lte: toDate },
|
|
701
|
-
userEmail: { $in: getUserEmails },
|
|
702
|
-
$or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ],
|
|
698
|
+
$or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
|
|
703
699
|
} },
|
|
704
700
|
{
|
|
705
701
|
$project: {
|
|
@@ -828,8 +824,7 @@ export const flagTablesV1 = async ( req, res ) => {
|
|
|
828
824
|
{ $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
|
|
829
825
|
{ date_iso: { $gte: fromDate } },
|
|
830
826
|
{ date_iso: { $lte: toDate } },
|
|
831
|
-
{ userEmail: { $in: getUserEmails } },
|
|
832
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
827
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
833
828
|
);
|
|
834
829
|
|
|
835
830
|
if ( requestData?.filter === 'all' ) {
|
|
@@ -1886,8 +1881,7 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
|
|
|
1886
1881
|
{ date_iso: { $lte: dayjs.utc( reqestData.toDate ).endOf( 'day' ).toDate() } },
|
|
1887
1882
|
{ sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.sourceCheckList_id ) },
|
|
1888
1883
|
// { store_id: { $in: reqestData?.storeId } },
|
|
1889
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1890
|
-
{ $or: [ { store_id: { $in: reqestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1884
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1891
1885
|
],
|
|
1892
1886
|
},
|
|
1893
1887
|
},
|
|
@@ -2111,8 +2105,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
|
|
|
2111
2105
|
{ date_iso: { $lte: rangeOneToDate } },
|
|
2112
2106
|
{ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
|
|
2113
2107
|
// { store_id: { $in: requestData?.storeId } },
|
|
2114
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2115
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2108
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2116
2109
|
],
|
|
2117
2110
|
},
|
|
2118
2111
|
},
|
|
@@ -2405,8 +2398,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
|
|
|
2405
2398
|
// ],
|
|
2406
2399
|
// },
|
|
2407
2400
|
// { store_id: { $in: reqestData?.storeId } },
|
|
2408
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2409
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2401
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2410
2402
|
],
|
|
2411
2403
|
},
|
|
2412
2404
|
};
|
|
@@ -2682,8 +2674,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
|
|
|
2682
2674
|
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } },
|
|
2683
2675
|
],
|
|
2684
2676
|
},
|
|
2685
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2686
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2677
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2687
2678
|
] } },
|
|
2688
2679
|
{
|
|
2689
2680
|
$project: {
|
|
@@ -863,7 +863,7 @@ export const assignedUserDetails = async ( req, res ) => {
|
|
|
863
863
|
let page = parseInt( req.query.offset ) || 0;
|
|
864
864
|
let skip = limit * page;
|
|
865
865
|
|
|
866
|
-
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), isdeleted: false } } ];
|
|
866
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), ...( req.query.coverage ) ? { coverage: req.query.coverage } : {}, isdeleted: false } } ];
|
|
867
867
|
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
868
868
|
let searchValue = req.query.search;
|
|
869
869
|
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
@@ -972,7 +972,7 @@ export const assignedUserDetailsv1 = async ( req, res ) => {
|
|
|
972
972
|
// let page = parseInt( req.query.offset ) || 0;
|
|
973
973
|
// let skip = limit * page;
|
|
974
974
|
|
|
975
|
-
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), isdeleted: false } } ];
|
|
975
|
+
let query = [ { $match: { checkListId: new ObjectId( req.params.checklistId ), ...( req.query.coverage ) ? { coverage: req.query.coverage } : {}, isdeleted: false } } ];
|
|
976
976
|
if ( req.query.search.trim() && req.query.search.trim() != '' ) {
|
|
977
977
|
let searchValue = req.query.search;
|
|
978
978
|
searchValue = searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
@@ -3638,7 +3638,7 @@ async function assignUsers( data ) {
|
|
|
3638
3638
|
];
|
|
3639
3639
|
let storeDetails = await storeService.aggregate( query );
|
|
3640
3640
|
if ( storeDetails.length ) {
|
|
3641
|
-
let email = data?.upload ? data.userEmail : storeDetails?.[0]?.spocDetails?.email;
|
|
3641
|
+
let email = data?.upload ? data.userEmail : storeDetails?.[0]?.spocDetails?.[0]?.email;
|
|
3642
3642
|
let userDetails = await userService.findOne( { email: email, clientId: data.clientId } );
|
|
3643
3643
|
if ( !userDetails ) {
|
|
3644
3644
|
let userData = {
|
|
@@ -3764,7 +3764,7 @@ export async function checklistAssign( req, res ) {
|
|
|
3764
3764
|
return res.sendError( 'No data found', 204 );
|
|
3765
3765
|
}
|
|
3766
3766
|
assignList = await Promise.all( getStoreDetails.map( async ( store ) => {
|
|
3767
|
-
let userDetails = await userService.findOne( { email: store?.spocDetails?.email, clientId: store.clientId } );
|
|
3767
|
+
let userDetails = await userService.findOne( { email: store?.spocDetails?.[0]?.email, clientId: store.clientId } );
|
|
3768
3768
|
if ( !userDetails ) {
|
|
3769
3769
|
let data = {
|
|
3770
3770
|
clientId: store.clientId,
|
|
@@ -289,8 +289,7 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
289
289
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
290
290
|
{ client_id: requestData.clientId },
|
|
291
291
|
// { store_id: { $in: requestData.storeId } },
|
|
292
|
-
{ userEmail: { $in: getUserEmails } },
|
|
293
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
292
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
294
293
|
);
|
|
295
294
|
|
|
296
295
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -476,8 +475,7 @@ export const storePerformance = async ( req, res ) => {
|
|
|
476
475
|
{ date_iso: { $lte: toDate } },
|
|
477
476
|
{ checkListType: { $eq: 'custom' } },
|
|
478
477
|
// { store_id: { $in: requestData.storeId } },
|
|
479
|
-
{ userEmail: { $in: getUserEmails } },
|
|
480
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
478
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
481
479
|
);
|
|
482
480
|
|
|
483
481
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -687,8 +685,7 @@ export const userPerformance = async ( req, res ) => {
|
|
|
687
685
|
{ checkListType: { $eq: 'custom' } },
|
|
688
686
|
{ client_id: requestData.clientId },
|
|
689
687
|
// { store_id: { $in: requestData.storeId } },
|
|
690
|
-
{ userEmail: { $in: getUserEmails } },
|
|
691
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
688
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
692
689
|
);
|
|
693
690
|
|
|
694
691
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -991,8 +988,7 @@ export const storeDropdown = async ( req, res ) => {
|
|
|
991
988
|
{ date_iso: { $gte: fromDate } },
|
|
992
989
|
{ date_iso: { $lte: toDate } },
|
|
993
990
|
// { store_id: { $in: requestData.storeId } },
|
|
994
|
-
{ userEmail: { $in: getUserEmails } },
|
|
995
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
991
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
996
992
|
);
|
|
997
993
|
|
|
998
994
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -1115,8 +1111,7 @@ export const userDropdown = async ( req, res ) => {
|
|
|
1115
1111
|
{ date_iso: { $gte: fromDate } },
|
|
1116
1112
|
{ date_iso: { $lte: toDate } },
|
|
1117
1113
|
// { store_id: { $in: requestData.storeId } },
|
|
1118
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1119
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1114
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1120
1115
|
);
|
|
1121
1116
|
|
|
1122
1117
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -1220,8 +1215,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1220
1215
|
{ date_iso: { $lte: toDate } },
|
|
1221
1216
|
{ checkListType: { $eq: 'custom' } },
|
|
1222
1217
|
// { store_id: { $in: requestData.storeId } },
|
|
1223
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1224
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1218
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1225
1219
|
);
|
|
1226
1220
|
|
|
1227
1221
|
if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
|
|
@@ -1275,6 +1269,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1275
1269
|
findQuery.push( {
|
|
1276
1270
|
$project: {
|
|
1277
1271
|
checkListName: 1,
|
|
1272
|
+
coverage: 1,
|
|
1278
1273
|
createdByName: 1,
|
|
1279
1274
|
userName: 1,
|
|
1280
1275
|
userEmail: 1,
|
|
@@ -1298,6 +1293,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1298
1293
|
findQuery.push( {
|
|
1299
1294
|
$project: {
|
|
1300
1295
|
checkListName: 1,
|
|
1296
|
+
coverage: 1,
|
|
1301
1297
|
checkListChar: { $substr: [ '$checkListName', 0, 2 ] },
|
|
1302
1298
|
createdByName: 1,
|
|
1303
1299
|
userName: 1,
|
|
@@ -1423,8 +1419,7 @@ export const infoCardsOld = async ( req, res ) => {
|
|
|
1423
1419
|
{ date_iso: { $gte: fromDate } },
|
|
1424
1420
|
{ date_iso: { $lte: toDate } },
|
|
1425
1421
|
// { store_id: { $in: requestData.storeId } },
|
|
1426
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1427
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1422
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1428
1423
|
);
|
|
1429
1424
|
|
|
1430
1425
|
if ( requestData.groupByType == 'checklist' ) {
|
|
@@ -1714,8 +1709,7 @@ export const flagDetectionCards = async ( req, res ) => {
|
|
|
1714
1709
|
{ date_iso: { $gte: fromDate } },
|
|
1715
1710
|
{ date_iso: { $lte: toDate } },
|
|
1716
1711
|
// { store_id: { $in: requestData.storeId } },
|
|
1717
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1718
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1712
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1719
1713
|
);
|
|
1720
1714
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
1721
1715
|
|
|
@@ -1879,8 +1873,7 @@ export const flagDetectionTables = async ( req, res ) => {
|
|
|
1879
1873
|
{ date_iso: { $lte: toDate } },
|
|
1880
1874
|
{ checklistStatus: { $eq: 'submit' } },
|
|
1881
1875
|
// { store_id: { $in: requestData.storeId } },
|
|
1882
|
-
{ userEmail: { $in: getUserEmails } },
|
|
1883
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
1876
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
1884
1877
|
);
|
|
1885
1878
|
|
|
1886
1879
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -2226,8 +2219,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2226
2219
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
2227
2220
|
{ client_id: requestData.clientId },
|
|
2228
2221
|
// { store_id: { $in: requestData.storeId } },
|
|
2229
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2230
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2222
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2231
2223
|
);
|
|
2232
2224
|
|
|
2233
2225
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -2476,8 +2468,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2476
2468
|
{ date_iso: { $gte: rangeOneFromDate, $lte: rangeOneToDate } },
|
|
2477
2469
|
{ client_id: requestData.clientId },
|
|
2478
2470
|
// { store_id: { $in: requestData.storeId } },
|
|
2479
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2480
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2471
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2481
2472
|
);
|
|
2482
2473
|
|
|
2483
2474
|
rangeOneFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
|
|
@@ -2575,8 +2566,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2575
2566
|
{ date_iso: { $gte: rangeTwoFromDate, $lte: rangeTwoToDate } },
|
|
2576
2567
|
{ client_id: requestData.clientId },
|
|
2577
2568
|
// { store_id: { $in: requestData.storeId } },
|
|
2578
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2579
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2569
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2580
2570
|
);
|
|
2581
2571
|
|
|
2582
2572
|
rangeTwoFindQuery.push( { $match: { $and: rangeTwoFindAndQuery } } );
|
|
@@ -2728,8 +2718,7 @@ export const infoCardsV1 = async ( req, res ) => {
|
|
|
2728
2718
|
{ date_iso: { $lte: toDate } },
|
|
2729
2719
|
{ checkListType: { $eq: 'custom' } },
|
|
2730
2720
|
// { store_id: { $in: requestData.storeId } },
|
|
2731
|
-
{ userEmail: { $in: getUserEmails } },
|
|
2732
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
2721
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
2733
2722
|
);
|
|
2734
2723
|
|
|
2735
2724
|
if ( requestData.groupByType == 'Checklist' ) {
|
|
@@ -3012,8 +3001,7 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
|
|
|
3012
3001
|
{ date_iso: { $lte: rangeOneToDate } },
|
|
3013
3002
|
{ checkListType: { $eq: 'custom' } },
|
|
3014
3003
|
// { store_id: { $in: requestData.storeId } },
|
|
3015
|
-
{ userEmail: { $in: getUserEmails } },
|
|
3016
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
3004
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
3017
3005
|
);
|
|
3018
3006
|
|
|
3019
3007
|
if ( requestData.groupByType == 'Checklist' ) {
|
|
@@ -3132,8 +3120,7 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
|
|
|
3132
3120
|
{ date_iso: { $lte: rangeTwoToDate } },
|
|
3133
3121
|
{ checkListType: { $eq: 'custom' } },
|
|
3134
3122
|
// { store_id: { $in: requestData.storeId } },
|
|
3135
|
-
{ userEmail: { $in: getUserEmails } },
|
|
3136
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
3123
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
3137
3124
|
);
|
|
3138
3125
|
if ( requestData.groupByType == 'Checklist' ) {
|
|
3139
3126
|
rangeTwoFindAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.groupByValue ) } );
|
|
@@ -3332,8 +3319,7 @@ export const monthlyGraphV1 = async ( req, res ) => {
|
|
|
3332
3319
|
{ date_iso: { $lte: toDate } },
|
|
3333
3320
|
{ checkListType: { $eq: 'custom' } },
|
|
3334
3321
|
// { store_id: { $in: requestData.storeId } },
|
|
3335
|
-
{ userEmail: { $in: getUserEmails } },
|
|
3336
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
3322
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
3337
3323
|
);
|
|
3338
3324
|
|
|
3339
3325
|
if ( requestData.groupByType == 'Checklist' ) {
|
|
@@ -3573,8 +3559,7 @@ export const checklistDropdown = async ( req, res ) => {
|
|
|
3573
3559
|
{ date_iso: { $gte: fromDate, $lte: toDate } },
|
|
3574
3560
|
{ checkListType: 'custom' },
|
|
3575
3561
|
// { store_id: { $in: requestData.storeId } },
|
|
3576
|
-
{ userEmail: { $in: getUserEmails } },
|
|
3577
|
-
{ $or: [ { store_id: { $in: requestData.storeId || '' } }, { store_id: { $eq: '' } } ] },
|
|
3562
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
|
|
3578
3563
|
] } },
|
|
3579
3564
|
{
|
|
3580
3565
|
$project: {
|