tango-app-api-audit 3.5.37 → 3.5.39
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
|
@@ -1201,15 +1201,45 @@ export async function summaryList( req, res ) {
|
|
|
1201
1201
|
{ $unwind: { path: '$stores', preserveNullAndEmptyArrays: true } },
|
|
1202
1202
|
{
|
|
1203
1203
|
$group: {
|
|
1204
|
-
_id: { clusterName: '$clusterName',
|
|
1204
|
+
_id: { clusterName: '$clusterName', RMEmail: '$Teamlead.email' },
|
|
1205
1205
|
clusterName: { $first: '$clusterName' },
|
|
1206
|
-
|
|
1206
|
+
RMEmail: { $first: '$Teamlead.email' },
|
|
1207
1207
|
store: { $addToSet: '$stores.storeId' },
|
|
1208
1208
|
|
|
1209
1209
|
},
|
|
1210
1210
|
},
|
|
1211
|
+
{
|
|
1212
|
+
$lookup: {
|
|
1213
|
+
from: 'users',
|
|
1214
|
+
let: { email: '$RMEmail' },
|
|
1215
|
+
pipeline: [
|
|
1216
|
+
{
|
|
1217
|
+
$match: {
|
|
1218
|
+
$expr: {
|
|
1219
|
+
$and: [
|
|
1220
|
+
{
|
|
1221
|
+
$eq: [ '$email', '$$email' ],
|
|
1222
|
+
},
|
|
1223
|
+
],
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
$project: {
|
|
1229
|
+
userName: 1,
|
|
1230
|
+
},
|
|
1231
|
+
},
|
|
1232
|
+
], as: 'userName',
|
|
1233
|
+
},
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
$unwind: {
|
|
1237
|
+
path: '$userName', preserveNullAndEmptyArrays: true,
|
|
1238
|
+
},
|
|
1239
|
+
},
|
|
1211
1240
|
{ $project: {
|
|
1212
|
-
|
|
1241
|
+
RMEmail: 1,
|
|
1242
|
+
RMName: '$userName.userName',
|
|
1213
1243
|
clusterName: 1,
|
|
1214
1244
|
storesCount: { $size: '$store' },
|
|
1215
1245
|
store: 1,
|
|
@@ -1237,13 +1267,13 @@ export async function summaryList( req, res ) {
|
|
|
1237
1267
|
$group: {
|
|
1238
1268
|
_id: '$Teamlead.email',
|
|
1239
1269
|
clusterName: { $addToSet: '$clusterName' },
|
|
1240
|
-
|
|
1270
|
+
RMEmail: { $first: '$Teamlead.email' },
|
|
1241
1271
|
store: { $addToSet: '$stores.storeId' },
|
|
1242
1272
|
|
|
1243
1273
|
},
|
|
1244
1274
|
},
|
|
1245
1275
|
{ $project: {
|
|
1246
|
-
|
|
1276
|
+
RMEmail: 1,
|
|
1247
1277
|
clusterCount1: { $size: '$clusterName' },
|
|
1248
1278
|
storesCount1: { $size: '$store' },
|
|
1249
1279
|
store: 1,
|
|
@@ -1259,14 +1289,45 @@ export async function summaryList( req, res ) {
|
|
|
1259
1289
|
},
|
|
1260
1290
|
},
|
|
1261
1291
|
{
|
|
1262
|
-
$
|
|
1292
|
+
$lookup: {
|
|
1293
|
+
from: 'users',
|
|
1294
|
+
let: { email: '$RMEmail' },
|
|
1295
|
+
pipeline: [
|
|
1296
|
+
{
|
|
1297
|
+
$match: {
|
|
1298
|
+
$expr: {
|
|
1299
|
+
$and: [
|
|
1300
|
+
{
|
|
1301
|
+
$eq: [ '$email', '$$email' ],
|
|
1302
|
+
},
|
|
1303
|
+
],
|
|
1304
|
+
},
|
|
1305
|
+
},
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
$project: {
|
|
1309
|
+
userName: 1,
|
|
1310
|
+
},
|
|
1311
|
+
},
|
|
1312
|
+
], as: 'userName',
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
$unwind: {
|
|
1317
|
+
path: '$userName', preserveNullAndEmptyArrays: true,
|
|
1318
|
+
},
|
|
1263
1319
|
},
|
|
1320
|
+
|
|
1264
1321
|
{ $project: {
|
|
1265
|
-
RMName:
|
|
1322
|
+
RMName: '$userName.userName',
|
|
1323
|
+
RMEmail: 1,
|
|
1266
1324
|
clusterCount: 1,
|
|
1267
1325
|
storesCount: 1,
|
|
1268
1326
|
store: 1,
|
|
1269
1327
|
} },
|
|
1328
|
+
{
|
|
1329
|
+
$sort: sort,
|
|
1330
|
+
},
|
|
1270
1331
|
];
|
|
1271
1332
|
const getcount = await aggregateClusters( inputData.keyType === 'rm'?RMQuery: clusterQuery );
|
|
1272
1333
|
const count = getcount?.length || 0;
|
|
@@ -1292,13 +1353,11 @@ export async function summaryList( req, res ) {
|
|
|
1292
1353
|
);
|
|
1293
1354
|
}
|
|
1294
1355
|
const getCluster = await aggregateClusters( inputData.keyType === 'rm'?RMQuery: clusterQuery );
|
|
1295
|
-
logger.info( { getCluster: getCluster } );
|
|
1296
1356
|
if ( !getCluster || getCluster?.length == 0 ) {
|
|
1297
1357
|
return res.sendError( 'No data', 204 );
|
|
1298
1358
|
}
|
|
1299
1359
|
const temp =[];
|
|
1300
1360
|
for ( const [ i, cluster ] of getCluster.entries() ) {
|
|
1301
|
-
logger.info( { cluster: cluster } );
|
|
1302
1361
|
temp.push( cluster );
|
|
1303
1362
|
const getClusterQuery= {
|
|
1304
1363
|
'size': 0,
|
|
@@ -1345,8 +1404,8 @@ export async function summaryList( req, res ) {
|
|
|
1345
1404
|
delete temp[i]._id;
|
|
1346
1405
|
temp[i].totalFiles = getResponse?.body?.aggregations?.total_count?.value || 0,
|
|
1347
1406
|
temp[i].completedFiles=getResponse?.body?.aggregations?.audited_trustScore?.totalCount?.value || 0;
|
|
1348
|
-
temp[i].complianceScore = getResponse?.body?.aggregations?.avg_complianceScore?.value || 0
|
|
1349
|
-
temp[i].trustScore
|
|
1407
|
+
temp[i].complianceScore = `${ Math.round( getResponse?.body?.aggregations?.avg_complianceScore?.value || 0 )} %`;
|
|
1408
|
+
temp[i].trustScore =`${getResponse?.body?.aggregations?.audited_trustScore?.totalCount?.value + ' %' || 'NA'}`;
|
|
1350
1409
|
}
|
|
1351
1410
|
}
|
|
1352
1411
|
|
|
@@ -1362,8 +1421,8 @@ export async function summaryList( req, res ) {
|
|
|
1362
1421
|
'Store Count': element?.storesCount,
|
|
1363
1422
|
'Total Tango AI Files': element.totalFiles,
|
|
1364
1423
|
'Trust Audit Completed': element.completedFiles,
|
|
1365
|
-
'Tango Score': element?.
|
|
1366
|
-
'Trust Score': element?.trustScore
|
|
1424
|
+
'Tango Score': element?.complianceScore,
|
|
1425
|
+
'Trust Score': element?.trustScore,
|
|
1367
1426
|
|
|
1368
1427
|
|
|
1369
1428
|
} );
|
|
@@ -1373,8 +1432,8 @@ export async function summaryList( req, res ) {
|
|
|
1373
1432
|
'Store Count': element?.storesCount,
|
|
1374
1433
|
'Total Tango AI Files': element.totalFiles,
|
|
1375
1434
|
'Trust Audit Completed': element.completedFiles,
|
|
1376
|
-
'Tango Score': element?.
|
|
1377
|
-
'Trust Score': element?.trustScore
|
|
1435
|
+
'Tango Score': element?.complianceScore,
|
|
1436
|
+
'Trust Score': element?.trustScore,
|
|
1378
1437
|
|
|
1379
1438
|
} );
|
|
1380
1439
|
}
|
|
@@ -1522,10 +1581,10 @@ export async function summaryList( req, res ) {
|
|
|
1522
1581
|
'bool': search,
|
|
1523
1582
|
},
|
|
1524
1583
|
'sort': [
|
|
1525
|
-
{
|
|
1584
|
+
{ [sortBy]: { order: order === -1 ?'desc':'asc' } },
|
|
1585
|
+
{ '_id': 'asc' },
|
|
1526
1586
|
],
|
|
1527
1587
|
};
|
|
1528
|
-
// allResult =await fetchAllDocuments( openSearch.EyeTestInput, search );
|
|
1529
1588
|
}
|
|
1530
1589
|
|
|
1531
1590
|
const countQuery = {
|
|
@@ -1559,12 +1618,17 @@ export async function summaryList( req, res ) {
|
|
|
1559
1618
|
}
|
|
1560
1619
|
|
|
1561
1620
|
let RMName = '';
|
|
1621
|
+
let RMEmail = '';
|
|
1562
1622
|
let clusterName='';
|
|
1563
1623
|
if ( element?._source?.storeId&&element?._source?.storeId!='' ) {
|
|
1564
1624
|
const getCluster = await findOneClusters( { 'stores.storeId': element?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1565
|
-
|
|
1625
|
+
RMEmail =( getCluster && getCluster.Teamlead?.length > 0 )? getCluster?.Teamlead?.[0]?.email : '';
|
|
1566
1626
|
clusterName = getCluster?.clusterName;
|
|
1567
1627
|
}
|
|
1628
|
+
if ( RMEmail ) {
|
|
1629
|
+
const temp = await findOneUser( { email: RMEmail }, { userName: 1 } );
|
|
1630
|
+
RMName = temp?.userName;
|
|
1631
|
+
}
|
|
1568
1632
|
if ( element?._source?.type == 'physical' ) {
|
|
1569
1633
|
exportData.push( {
|
|
1570
1634
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
@@ -1575,9 +1639,9 @@ export async function summaryList( req, res ) {
|
|
|
1575
1639
|
'Store Name': element?._source?.storeName ||'Un Assigned',
|
|
1576
1640
|
'Optum ID': element?._source?.optumId,
|
|
1577
1641
|
'Queue ID': element?._source?.queueId,
|
|
1578
|
-
'
|
|
1642
|
+
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1579
1643
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1580
|
-
'Trust Score': element?._source?.trustScore || 0
|
|
1644
|
+
'Trust Score': `${element?._source?.trustScore || 0} %`,
|
|
1581
1645
|
'Visitor Type': element?._source?.visitorsType,
|
|
1582
1646
|
'Test Duration': duration || '',
|
|
1583
1647
|
'Audit Status': element?._source?.auditStatus || '',
|
|
@@ -1593,9 +1657,9 @@ export async function summaryList( req, res ) {
|
|
|
1593
1657
|
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
1594
1658
|
'Store Name': element?._source?.storeName ||'Un Assigned',
|
|
1595
1659
|
'Engagement ID': element?._source?.engagementId,
|
|
1596
|
-
'
|
|
1660
|
+
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1597
1661
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1598
|
-
'Trust Score': element?._source?.trustScore ||0
|
|
1662
|
+
'Trust Score': `${element?._source?.trustScore ||0}`,
|
|
1599
1663
|
'Test Duration': duration || '',
|
|
1600
1664
|
'Audit Status': element?._source?.auditStatus || '',
|
|
1601
1665
|
'Audited By': userName?.userName || '',
|
|
@@ -1618,25 +1682,31 @@ export async function summaryList( req, res ) {
|
|
|
1618
1682
|
userName = await findOneUser( { _id: item?._source?.userId }, { _id: 0, userName: 1 } );
|
|
1619
1683
|
}
|
|
1620
1684
|
let RMName = '';
|
|
1685
|
+
let RMEmail = '';
|
|
1621
1686
|
let clusterName='';
|
|
1622
1687
|
if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
|
|
1623
1688
|
const getCluster = await findOneClusters( { 'stores.storeId': item?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1624
|
-
|
|
1689
|
+
RMEmail =( getCluster && getCluster.Teamlead?.length > 0 )? getCluster?.Teamlead?.[0]?.email : '';
|
|
1625
1690
|
clusterName = getCluster?.clusterName;
|
|
1626
1691
|
}
|
|
1627
|
-
|
|
1692
|
+
if ( RMEmail ) {
|
|
1693
|
+
const temp = await findOneUser( { email: RMEmail }, { userName: 1 } );
|
|
1694
|
+
RMName = temp?.userName;
|
|
1695
|
+
}
|
|
1628
1696
|
const testDuration = item?._source?.testDuration;
|
|
1629
1697
|
const minutes = Math.floor( testDuration / 60 );
|
|
1630
1698
|
const seconds = testDuration % 60;
|
|
1631
|
-
temp[i].complianceScore = item?._source?.totalSteps>0 ? Math.round( ( item?._source?.coveredStepsAI/ item?._source?.totalSteps )*100 ): 0
|
|
1699
|
+
temp[i].complianceScore = `${item?._source?.totalSteps>0 ? Math.round( ( item?._source?.coveredStepsAI/ item?._source?.totalSteps )*100 ): 0} %`;
|
|
1632
1700
|
temp[i].min = minutes;
|
|
1633
1701
|
temp[i].sec = seconds;
|
|
1634
1702
|
temp[i].auditedBy = userName?.userName || '';
|
|
1635
1703
|
temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
|
|
1636
1704
|
temp[i].RMName = RMName;
|
|
1637
1705
|
temp[i].clusterName =clusterName;
|
|
1706
|
+
temp[i].RMEmail =RMEmail;
|
|
1707
|
+
const trustScore = temp[i].trustScore;
|
|
1708
|
+
temp[i].trustScore = ( trustScore == null || trustScore == undefined ) ? 'NA' :`${trustScore + ' %'}`;
|
|
1638
1709
|
}
|
|
1639
|
-
logger.info( { temp: temp } );
|
|
1640
1710
|
}
|
|
1641
1711
|
|
|
1642
1712
|
return res.sendSuccess( { result: temp, count: count } );
|
|
@@ -1738,7 +1808,7 @@ export async function summaryCard( req, res ) {
|
|
|
1738
1808
|
// { date: { order: 'desc' } },
|
|
1739
1809
|
// ],
|
|
1740
1810
|
script_fields: {
|
|
1741
|
-
//
|
|
1811
|
+
// makes coveragePercentage visible inside hits
|
|
1742
1812
|
coveragePercentage: {
|
|
1743
1813
|
script: {
|
|
1744
1814
|
source: `
|
|
@@ -1870,15 +1940,17 @@ export async function summaryCard( req, res ) {
|
|
|
1870
1940
|
tangoScore: 0,
|
|
1871
1941
|
tangoScoreTrend: 0,
|
|
1872
1942
|
trustScore: 0,
|
|
1943
|
+
trend: false,
|
|
1873
1944
|
};
|
|
1874
1945
|
if ( getOutput?.body?.aggregations?.all_docs?.wrapper?.buckets?.filtered ) {
|
|
1875
1946
|
const temp= getOutput?.body?.aggregations?.all_docs?.wrapper?.buckets?.filtered;
|
|
1876
1947
|
initialValue.totalFiles =temp?.totalFiles?.value;
|
|
1877
1948
|
initialValue.completedFiles =temp?.completedFiles?.doc_count;
|
|
1878
1949
|
initialValue.completedRatio =temp?.completedRatio?.value || 0;
|
|
1879
|
-
initialValue.tangoScore =temp?.tangoScore?.value || 0;
|
|
1950
|
+
initialValue.tangoScore =Math.round( temp?.tangoScore?.value || 0 );
|
|
1880
1951
|
initialValue.tangoScoreTrend =temp?.tangoScoreTrend?.value || 0;
|
|
1881
|
-
initialValue.trustScore =temp?.trustScore?.avg_val?.value == null ? 'NA':temp?.trustScore?.avg_val?.value;
|
|
1952
|
+
initialValue.trustScore =temp?.trustScore?.avg_val?.value == null || temp?.trustScore?.avg_val?.value === undefined ? 'NA':Math.round( temp?.trustScore?.avg_val?.value );
|
|
1953
|
+
initialValue.trend = initialValue.tangoScoreTrend < 0? false : true;
|
|
1882
1954
|
}
|
|
1883
1955
|
const result = initialValue;
|
|
1884
1956
|
|