tango-app-api-trax 3.5.0-hotfix-2 → 3.5.0-hotfix-3
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.5.0-hotfix-
|
|
3
|
+
"version": "3.5.0-hotfix-3",
|
|
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.120",
|
|
30
30
|
"tango-app-api-middleware": "^3.1.77",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
@@ -1068,10 +1068,10 @@ export async function userList( req, res ) {
|
|
|
1068
1068
|
},
|
|
1069
1069
|
}, clientId: req.body.clientId } );
|
|
1070
1070
|
req.body.teams = findTeams.map( ( data ) => data.teamName );
|
|
1071
|
-
|
|
1071
|
+
if ( req.body.teams.length===0 ) {
|
|
1072
1072
|
query.push( {
|
|
1073
1073
|
$match: {
|
|
1074
|
-
userEmail: { $in: [req.user.email] },
|
|
1074
|
+
userEmail: { $in: [ req.user.email ] },
|
|
1075
1075
|
},
|
|
1076
1076
|
} );
|
|
1077
1077
|
}
|
|
@@ -4,6 +4,7 @@ import dayjs from 'dayjs';
|
|
|
4
4
|
import * as processedchecklistService from '../services/processedchecklist.services.js';
|
|
5
5
|
import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
|
|
6
6
|
import * as checklistconfigService from '../services/checklist.service.js';
|
|
7
|
+
import * as clientService from '../services/clients.services.js';
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
import utc from 'dayjs/plugin/utc.js';
|
|
@@ -2096,6 +2097,12 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
|
|
|
2096
2097
|
},
|
|
2097
2098
|
};
|
|
2098
2099
|
|
|
2100
|
+
let traxMonthlyComparison = false;
|
|
2101
|
+
let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
|
|
2102
|
+
if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
|
|
2103
|
+
traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2099
2106
|
// Get User Based Checklist //
|
|
2100
2107
|
// let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
2101
2108
|
// let getUserEmails = await getChecklistUsers( loginUser );
|
|
@@ -2295,6 +2302,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
|
|
|
2295
2302
|
|
|
2296
2303
|
let result = {
|
|
2297
2304
|
'customCards': flagComparisonCards,
|
|
2305
|
+
'traxMonthlyComparison': traxMonthlyComparison,
|
|
2298
2306
|
};
|
|
2299
2307
|
|
|
2300
2308
|
return res.sendSuccess( result );
|
|
@@ -2324,7 +2332,6 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
|
|
|
2324
2332
|
];
|
|
2325
2333
|
const from = await aggregate( fromPipeline );
|
|
2326
2334
|
requestData.range1StoreCount = from[0]?.storeCount | 0;
|
|
2327
|
-
|
|
2328
2335
|
const toPipeline = [
|
|
2329
2336
|
{
|
|
2330
2337
|
$match:
|
|
@@ -2357,6 +2364,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
|
|
|
2357
2364
|
// console.log( 'resultData =>', resultData );
|
|
2358
2365
|
if ( resultData ) {
|
|
2359
2366
|
if ( resultData.status_code == '200' ) {
|
|
2367
|
+
resultData.traxMonthlyComparison = traxMonthlyComparison;
|
|
2360
2368
|
return res.sendSuccess( resultData );
|
|
2361
2369
|
} else {
|
|
2362
2370
|
return res.sendError( 'No Content', 204 );
|
|
@@ -2889,6 +2897,14 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
|
|
|
2889
2897
|
getDetectionCount( rangeTwoFromDate, rangeTwoToDate ),
|
|
2890
2898
|
] );
|
|
2891
2899
|
|
|
2900
|
+
// console.log( 'rangeOneFromDate =>', rangeOneFromDate );
|
|
2901
|
+
// console.log( 'rangeOneToDate =>', rangeOneToDate );
|
|
2902
|
+
// console.log( 'rangeOneData =>', rangeOneData );
|
|
2903
|
+
|
|
2904
|
+
// console.log( 'rangeTwoFromDate =>', rangeTwoFromDate );
|
|
2905
|
+
// console.log( 'rangeTwoToDate =>', rangeTwoToDate );
|
|
2906
|
+
// console.log( 'rangeTwoData =>', rangeTwoData );
|
|
2907
|
+
|
|
2892
2908
|
const flagComparisonCards = {
|
|
2893
2909
|
totalComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
|
|
2894
2910
|
questionComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
|
|
@@ -2904,7 +2920,11 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
|
|
|
2904
2920
|
flagComparisonCards.delayInSubmissionComparisonFlag = calculateComparison( rangeOneData[0].delayInSubmission, rangeTwoData[0].delayInSubmission );
|
|
2905
2921
|
flagComparisonCards.detectionComparisonFlag = calculateComparison( rangeOneDetectionCount, rangeTwoDetectionCount );
|
|
2906
2922
|
}
|
|
2907
|
-
|
|
2923
|
+
flagComparisonCards.traxMonthlyComparison = false;
|
|
2924
|
+
let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
|
|
2925
|
+
if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
|
|
2926
|
+
flagComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
|
|
2927
|
+
}
|
|
2908
2928
|
return res.sendSuccess( { flagComparisonCards } );
|
|
2909
2929
|
} catch ( error ) {
|
|
2910
2930
|
console.log( 'error =>', error );
|
|
@@ -9,7 +9,7 @@ import utc from 'dayjs/plugin/utc.js';
|
|
|
9
9
|
dayjs.extend( utc );
|
|
10
10
|
// import admin from 'firebase-admin';
|
|
11
11
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
12
|
-
|
|
12
|
+
import * as clientService from '../services/clients.services.js';
|
|
13
13
|
|
|
14
14
|
export const welcome = async ( req, res ) => {
|
|
15
15
|
try {
|
|
@@ -1165,7 +1165,7 @@ export const userDropdown = async ( req, res ) => {
|
|
|
1165
1165
|
}
|
|
1166
1166
|
};
|
|
1167
1167
|
|
|
1168
|
-
export const
|
|
1168
|
+
export const checklistInfoOld = async ( req, res ) => {
|
|
1169
1169
|
try {
|
|
1170
1170
|
let requestData = req.body;
|
|
1171
1171
|
let fromDate = new Date( requestData.fromDate );
|
|
@@ -1445,6 +1445,297 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
};
|
|
1447
1447
|
|
|
1448
|
+
export const checklistInfo = async ( req, res ) => {
|
|
1449
|
+
try {
|
|
1450
|
+
let requestData = req.body;
|
|
1451
|
+
let fromDate = new Date( requestData.fromDate );
|
|
1452
|
+
let toDate = new Date( requestData.toDate );
|
|
1453
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
1454
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
1455
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
1456
|
+
let result = {};
|
|
1457
|
+
|
|
1458
|
+
// Get User Based Checklist //
|
|
1459
|
+
// let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
1460
|
+
// let getUserEmails = await getChecklistUsers( loginUser );
|
|
1461
|
+
// End: Get User Based Checklist////
|
|
1462
|
+
|
|
1463
|
+
let findQuery = [];
|
|
1464
|
+
let findAndQuery = [];
|
|
1465
|
+
findAndQuery.push(
|
|
1466
|
+
{ client_id: requestData.clientId },
|
|
1467
|
+
{ date_iso: { $gte: fromDate } },
|
|
1468
|
+
{ date_iso: { $lte: toDate } },
|
|
1469
|
+
{ checkListType: { $eq: 'custom' } },
|
|
1470
|
+
// { store_id: { $in: requestData.storeId } },
|
|
1471
|
+
{ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
|
|
1472
|
+
);
|
|
1473
|
+
|
|
1474
|
+
if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
|
|
1475
|
+
if ( requestData.checklistStatus == 'redo' ) {
|
|
1476
|
+
findAndQuery.push( { redoStatus: true } );
|
|
1477
|
+
} else {
|
|
1478
|
+
findAndQuery.push( { checklistStatus: requestData.checklistStatus } );
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
if ( requestData.groupByType == 'Checklist' ) {
|
|
1483
|
+
findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.groupByValue ) } );
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
if ( requestData.groupByType == 'User' ) {
|
|
1487
|
+
findAndQuery.push( { userEmail: requestData.groupByValue } );
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
if ( requestData.groupByType == 'Store' ) {
|
|
1491
|
+
findAndQuery.push( { store_id: requestData.groupByValue } );
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
1495
|
+
|
|
1496
|
+
if ( requestData.searchValue && requestData.searchValue != '' ) {
|
|
1497
|
+
if ( requestData.groupByType == 'Checklist' ) {
|
|
1498
|
+
// findQuery.push( { $match: { $or: [ { storeName: { $regex: requestData.searchValue, $options: 'i' } } ] } } );
|
|
1499
|
+
let storeList = requestData.searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
1500
|
+
let query;
|
|
1501
|
+
if ( storeList.length > 1 ) {
|
|
1502
|
+
findQuery.push( { $addFields: { store: { $toLower: '$storeName' } } } );
|
|
1503
|
+
query = { store: { $in: storeList } };
|
|
1504
|
+
} else {
|
|
1505
|
+
query = { $or: [
|
|
1506
|
+
{ storeName: { $regex: requestData.searchValue.trim(), $options: 'i' } },
|
|
1507
|
+
{ userEmail: { $regex: requestData.searchValue.trim(), $options: 'i' } },
|
|
1508
|
+
{ userName: { $regex: requestData.searchValue.trim(), $options: 'i' } },
|
|
1509
|
+
] };
|
|
1510
|
+
}
|
|
1511
|
+
findQuery.push( { $match: { $or: [ query ] } } );
|
|
1512
|
+
} else {
|
|
1513
|
+
// findQuery.push( { $match: { $or: [ { checkListName: { $regex: requestData.searchValue, $options: 'i' } } ] } } );
|
|
1514
|
+
let checkListSearch = requestData.searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
|
|
1515
|
+
let query;
|
|
1516
|
+
if ( checkListSearch.length > 1 ) {
|
|
1517
|
+
findQuery.push( { $addFields: { cheklistlowercase: { $toLower: '$checkListName' } } } );
|
|
1518
|
+
query = { cheklistlowercase: { $in: checkListSearch } };
|
|
1519
|
+
} else {
|
|
1520
|
+
query = { checkListName: { $regex: requestData.searchValue.trim(), $options: 'i' } };
|
|
1521
|
+
}
|
|
1522
|
+
findQuery.push( { $match: { $or: [ query ] } } );
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
findQuery.push( { $sort: { _id: -1 } } );
|
|
1527
|
+
|
|
1528
|
+
// findQuery.push( {
|
|
1529
|
+
// $group: {
|
|
1530
|
+
// _id: { store: '$store_id', email: '$userEmail', checklistId: '$sourceCheckList_id' },
|
|
1531
|
+
// checkListName: { $first: '$checkListName' },
|
|
1532
|
+
// coverage: { $first: '$coverage' },
|
|
1533
|
+
// createdByName: { $first: '$createdByName' },
|
|
1534
|
+
// userName: { $first: '$userName' },
|
|
1535
|
+
// checklistStatus: { $last: '$checklistStatus' },
|
|
1536
|
+
// userEmail: { $first: '$userEmail' },
|
|
1537
|
+
// submitTime_string: { $push: '$submitTime_string' },
|
|
1538
|
+
// storeName: { $first: '$storeName' },
|
|
1539
|
+
// checkListType: { $first: '$checkListType' },
|
|
1540
|
+
// scheduleRepeatedType: { $first: '$scheduleRepeatedType' },
|
|
1541
|
+
// timeFlag: { $sum: '$timeFlag' },
|
|
1542
|
+
// questionFlag: { $sum: '$questionFlag' },
|
|
1543
|
+
// date_iso: { $first: '$date_iso' },
|
|
1544
|
+
// store_id: { $first: '$store_id' },
|
|
1545
|
+
// date_string: { $first: '$date_string' },
|
|
1546
|
+
// sourceCheckList_id: { $first: '$sourceCheckList_id' },
|
|
1547
|
+
// reinitiateStatus: { $first: '$reinitiateStatus' },
|
|
1548
|
+
// redoStatus: { $first: '$redoStatus' },
|
|
1549
|
+
// submitCount: { $sum: {
|
|
1550
|
+
// $cond: {
|
|
1551
|
+
// if: { $eq: [ '$checklistStatus', 'submit' ] },
|
|
1552
|
+
// then: 1,
|
|
1553
|
+
// else: 0,
|
|
1554
|
+
// },
|
|
1555
|
+
// } },
|
|
1556
|
+
// approvalByEmail: { $first: '$approvalByEmail' },
|
|
1557
|
+
// approvalTime_string: { $push: '$approvalTime_string' },
|
|
1558
|
+
// idList: { $push: '$_id' },
|
|
1559
|
+
// },
|
|
1560
|
+
// } );
|
|
1561
|
+
|
|
1562
|
+
findQuery.push( {
|
|
1563
|
+
$project: {
|
|
1564
|
+
_id: 0,
|
|
1565
|
+
idList: 1,
|
|
1566
|
+
checkListName: 1,
|
|
1567
|
+
coverage: 1,
|
|
1568
|
+
createdByName: 1,
|
|
1569
|
+
userName: 1,
|
|
1570
|
+
checklistStatus: 1,
|
|
1571
|
+
// userEmail: '$_id.email',
|
|
1572
|
+
// submitTime_string: { $arrayElemAt: [ '$submitTime_string', 0 ] },
|
|
1573
|
+
userEmail: 1,
|
|
1574
|
+
submitTime_string: 1,
|
|
1575
|
+
storeName: 1,
|
|
1576
|
+
checkListType: 1,
|
|
1577
|
+
scheduleRepeatedType: 1,
|
|
1578
|
+
timeFlag: 1,
|
|
1579
|
+
questionFlag: 1,
|
|
1580
|
+
date_iso: 1,
|
|
1581
|
+
// store_id: '$_id.store',
|
|
1582
|
+
store_id: 1,
|
|
1583
|
+
timeFlag: 1,
|
|
1584
|
+
date_string: 1,
|
|
1585
|
+
sourceCheckList_id: 1,
|
|
1586
|
+
reinitiateStatus: 1,
|
|
1587
|
+
redoStatus: 1,
|
|
1588
|
+
// submitCount: 1,
|
|
1589
|
+
submitCount: { $sum: {
|
|
1590
|
+
$cond: {
|
|
1591
|
+
if: { $eq: [ '$checklistStatus', 'submit' ] },
|
|
1592
|
+
then: 1,
|
|
1593
|
+
else: 0,
|
|
1594
|
+
},
|
|
1595
|
+
} },
|
|
1596
|
+
approvalByEmail: 1,
|
|
1597
|
+
approvalTime_string: 1,
|
|
1598
|
+
},
|
|
1599
|
+
} );
|
|
1600
|
+
|
|
1601
|
+
findQuery.push( {
|
|
1602
|
+
$project: {
|
|
1603
|
+
idList: 1,
|
|
1604
|
+
checkListName: 1,
|
|
1605
|
+
coverage: 1,
|
|
1606
|
+
checkListChar: { $substr: [ '$checkListName', 0, 2 ] },
|
|
1607
|
+
createdByName: 1,
|
|
1608
|
+
userName: 1,
|
|
1609
|
+
checklistStatus: {
|
|
1610
|
+
$cond: {
|
|
1611
|
+
if: { $eq: [ '$checklistStatus', 'submit' ] },
|
|
1612
|
+
then: 'Submitted',
|
|
1613
|
+
else: {
|
|
1614
|
+
$cond: {
|
|
1615
|
+
if: { $eq: [ '$checklistStatus', 'open' ] },
|
|
1616
|
+
then: 'Open',
|
|
1617
|
+
else: 'In Progress',
|
|
1618
|
+
},
|
|
1619
|
+
},
|
|
1620
|
+
},
|
|
1621
|
+
},
|
|
1622
|
+
userEmail: 1,
|
|
1623
|
+
// submitTime_string: 1,
|
|
1624
|
+
submitTime_string: {
|
|
1625
|
+
$cond: {
|
|
1626
|
+
if: { $eq: [ '$checklistStatus', 'submit' ] },
|
|
1627
|
+
then: '$submitTime_string',
|
|
1628
|
+
else: '',
|
|
1629
|
+
},
|
|
1630
|
+
},
|
|
1631
|
+
storeName: 1,
|
|
1632
|
+
checkListType: 1,
|
|
1633
|
+
scheduleRepeatedType: 1,
|
|
1634
|
+
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
1635
|
+
timeFlag: 1,
|
|
1636
|
+
questionFlag: 1,
|
|
1637
|
+
date_iso: 1,
|
|
1638
|
+
store_id: 1,
|
|
1639
|
+
timeFlag: 1,
|
|
1640
|
+
date_string: 1,
|
|
1641
|
+
checklistDate: '$date_string',
|
|
1642
|
+
sourceCheckList_id: 1,
|
|
1643
|
+
reinitiateStatus: 1,
|
|
1644
|
+
redoStatus: 1,
|
|
1645
|
+
submitCount: 1,
|
|
1646
|
+
approvalByEmail: 1,
|
|
1647
|
+
approvalTime_string: 1,
|
|
1648
|
+
},
|
|
1649
|
+
} );
|
|
1650
|
+
|
|
1651
|
+
// let getTotalCount = await processedchecklistService.aggregate( findQuery );
|
|
1652
|
+
// if ( !getTotalCount.length ) {
|
|
1653
|
+
// return res.sendError( { error: 'No Data Found' }, 204 );
|
|
1654
|
+
// }
|
|
1655
|
+
|
|
1656
|
+
if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
|
|
1657
|
+
findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
|
|
1658
|
+
}
|
|
1659
|
+
let limit = parseInt( requestData?.limit ) || 10;
|
|
1660
|
+
let skip = limit * ( requestData?.offset ) || 0;
|
|
1661
|
+
|
|
1662
|
+
findQuery.push(
|
|
1663
|
+
{
|
|
1664
|
+
$facet: {
|
|
1665
|
+
data: [
|
|
1666
|
+
{ $skip: skip }, { $limit: limit },
|
|
1667
|
+
],
|
|
1668
|
+
count: [
|
|
1669
|
+
{ $count: 'total' },
|
|
1670
|
+
],
|
|
1671
|
+
},
|
|
1672
|
+
},
|
|
1673
|
+
);
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
|
|
1677
|
+
if ( !getChecklistPerformanceData[0].data.length ) {
|
|
1678
|
+
return res.sendError( 'No data found', 204 );
|
|
1679
|
+
}
|
|
1680
|
+
result = {
|
|
1681
|
+
totalCount: getChecklistPerformanceData?.[0]?.count?.[0]?.total || 0,
|
|
1682
|
+
checklistInfo: getChecklistPerformanceData?.[0]?.data || [],
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
result.checklistInfo.forEach( ( item ) => {
|
|
1686
|
+
item.date_string = dayjs( item.date_string, 'YYYY-MM-DD' ).format( 'DD MMM YYYY' );
|
|
1687
|
+
} );
|
|
1688
|
+
if ( requestData.export ) {
|
|
1689
|
+
const exportdata = [];
|
|
1690
|
+
result.checklistInfo.forEach( ( element ) => {
|
|
1691
|
+
if ( requestData.groupByType==='Checklist' ) {
|
|
1692
|
+
exportdata.push( {
|
|
1693
|
+
'Date': element.date_string || '--',
|
|
1694
|
+
'Store Name': element.storeName || '--',
|
|
1695
|
+
'Checklist Owner': element.userName || '--',
|
|
1696
|
+
'Status': element.checklistStatus || '--',
|
|
1697
|
+
'Submitted By': element.userName || '--',
|
|
1698
|
+
'Submitted On': element.submitTime_string || '--',
|
|
1699
|
+
'Flags': element.flaggedChecklist || '--',
|
|
1700
|
+
'Approval By': element.approvalByEmail || '--',
|
|
1701
|
+
'Approval On': element.approvalTime_string || '--',
|
|
1702
|
+
} );
|
|
1703
|
+
} else if ( requestData.groupByType==='Store' ) {
|
|
1704
|
+
exportdata.push( {
|
|
1705
|
+
'CheckList Name': element.checkListName || '--',
|
|
1706
|
+
'Checklist Owner': element.userName || '--',
|
|
1707
|
+
'Status': element.checklistStatus || '--',
|
|
1708
|
+
'Submitted By': element.userName || '--',
|
|
1709
|
+
'Submitted On': element.submitTime_string || '--',
|
|
1710
|
+
'Flags': element.flaggedChecklist || '--',
|
|
1711
|
+
'Approval By': element.approvalByEmail || '--',
|
|
1712
|
+
'Approval On': element.approvalTime_string || '--',
|
|
1713
|
+
|
|
1714
|
+
} );
|
|
1715
|
+
} else {
|
|
1716
|
+
exportdata.push( {
|
|
1717
|
+
'Date': element.date_string || '--',
|
|
1718
|
+
'CheckList Name': element.checkListName || '--',
|
|
1719
|
+
'Store Name': element.storeName || '--',
|
|
1720
|
+
'Checklist Owner': element.userName || '--',
|
|
1721
|
+
'Status': element.checklistStatus || '--',
|
|
1722
|
+
'Submitted On': element.submitTime_string || '--',
|
|
1723
|
+
'Flags': element.flaggedChecklist || '--',
|
|
1724
|
+
'Approval By': element.approvalByEmail || '--',
|
|
1725
|
+
'Approval On': element.approvalTime_string || '--',
|
|
1726
|
+
} );
|
|
1727
|
+
}
|
|
1728
|
+
} );
|
|
1729
|
+
return await download( exportdata, res );
|
|
1730
|
+
}
|
|
1731
|
+
return res.sendSuccess( result );
|
|
1732
|
+
} catch ( error ) {
|
|
1733
|
+
console.log( 'error =>', error );
|
|
1734
|
+
logger.error( { error: error, message: req.query, function: 'checklistInfo' } );
|
|
1735
|
+
return res.sendError( { error: error }, 500 );
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1448
1739
|
export const infoCardsOld = async ( req, res ) => {
|
|
1449
1740
|
try {
|
|
1450
1741
|
let requestData = req.body;
|
|
@@ -2681,6 +2972,13 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2681
2972
|
overallComparisonCards.complianceRate.comparisonData = Math.abs( overallComparisonCards.complianceRate.comparisonData );
|
|
2682
2973
|
}
|
|
2683
2974
|
|
|
2975
|
+
overallComparisonCards.traxMonthlyComparison = false;
|
|
2976
|
+
let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
|
|
2977
|
+
// console.log( 'traxMonthlyComparisonData', traxMonthlyComparisonData );
|
|
2978
|
+
if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
|
|
2979
|
+
overallComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2684
2982
|
let result = {
|
|
2685
2983
|
'overallComparisonCards': overallComparisonCards,
|
|
2686
2984
|
};
|
|
@@ -3066,8 +3364,14 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
|
|
|
3066
3364
|
'flags': flags,
|
|
3067
3365
|
'completionScore': completionScore,
|
|
3068
3366
|
'complianceRate': complianceRate,
|
|
3367
|
+
'traxMonthlyComparison': false,
|
|
3069
3368
|
};
|
|
3070
3369
|
|
|
3370
|
+
let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
|
|
3371
|
+
if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
|
|
3372
|
+
infoComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3071
3375
|
// Get User Based Checklist //
|
|
3072
3376
|
// let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
|
|
3073
3377
|
// let getUserEmails = await getChecklistUsers( loginUser );
|
|
@@ -3220,7 +3524,11 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
|
|
|
3220
3524
|
let rangeTwoData = await processedchecklistService.aggregate( rangeTwoFindQuery );
|
|
3221
3525
|
|
|
3222
3526
|
if ( !rangeOneData.length ) {
|
|
3223
|
-
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
3527
|
+
// return res.sendError( { error: 'No Data Found' }, 204 );
|
|
3528
|
+
let result = {
|
|
3529
|
+
'infoComparisonCards': infoComparisonCards,
|
|
3530
|
+
};
|
|
3531
|
+
return res.sendSuccess( result );
|
|
3224
3532
|
}
|
|
3225
3533
|
|
|
3226
3534
|
if ( rangeOneData.length >0 && rangeTwoData.length >0 ) {
|