tango-app-api-audit 3.5.25 → 3.5.27
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
|
@@ -7,7 +7,7 @@ import timezone from 'dayjs/plugin/timezone.js';
|
|
|
7
7
|
import 'dayjs/locale/en.js';
|
|
8
8
|
import { findOneEyeTestConfig, updateOneEyeTestConfig } from '../service/eyeTestConfiguration.service.js';
|
|
9
9
|
import { ObjectId } from 'mongodb';
|
|
10
|
-
import { aggregateClusters } from '../service/clusters.service.js';
|
|
10
|
+
import { aggregateClusters, findOneClusters } from '../service/clusters.service.js';
|
|
11
11
|
|
|
12
12
|
dayjs.extend( utc );
|
|
13
13
|
dayjs.extend( timezone );
|
|
@@ -1081,6 +1081,56 @@ export async function userAuditedData( req, res ) {
|
|
|
1081
1081
|
export async function summaryList( req, res ) {
|
|
1082
1082
|
try {
|
|
1083
1083
|
const inputData = req.body;
|
|
1084
|
+
if ( inputData.clientId !== '11' ) {
|
|
1085
|
+
return res.sendError( 'No data found', 204 );
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1089
|
+
const limit = inputData.limit || 10;
|
|
1090
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1091
|
+
|
|
1092
|
+
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1093
|
+
const order = inputData?.sortOrder || -1;
|
|
1094
|
+
|
|
1095
|
+
let filter= [
|
|
1096
|
+
{
|
|
1097
|
+
'range': {
|
|
1098
|
+
'date': {
|
|
1099
|
+
'gte': new Date( inputData.fromDate ),
|
|
1100
|
+
'lte': new Date( inputData.toDate ),
|
|
1101
|
+
},
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
|
|
1105
|
+
];
|
|
1106
|
+
if ( inputData.demographics && inputData.demographics.length > 0 ) {
|
|
1107
|
+
filter.push( {
|
|
1108
|
+
'terms': {
|
|
1109
|
+
'visitorsType.keyword': inputData.demographics,
|
|
1110
|
+
},
|
|
1111
|
+
} );
|
|
1112
|
+
}
|
|
1113
|
+
if ( inputData.type && inputData.type!='' ) {
|
|
1114
|
+
filter.push( {
|
|
1115
|
+
'term': {
|
|
1116
|
+
'type.keyword': inputData.type,
|
|
1117
|
+
},
|
|
1118
|
+
|
|
1119
|
+
} );
|
|
1120
|
+
}
|
|
1121
|
+
if ( inputData.storeId && inputData.storeId.length > 0 ) {
|
|
1122
|
+
filter.push( {
|
|
1123
|
+
|
|
1124
|
+
'terms': {
|
|
1125
|
+
'storeId.keyword': inputData.storeId,
|
|
1126
|
+
},
|
|
1127
|
+
|
|
1128
|
+
} );
|
|
1129
|
+
} else {
|
|
1130
|
+
return res.sendError( 'No data found', 204 );
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
|
|
1084
1134
|
if ( inputData.keyType === 'rm' ) {
|
|
1085
1135
|
return res.sendSuccess( { result: [
|
|
1086
1136
|
{
|
|
@@ -1095,224 +1145,338 @@ export async function summaryList( req, res ) {
|
|
|
1095
1145
|
|
|
1096
1146
|
], count: 1 } );
|
|
1097
1147
|
} else if ( inputData.keyType === 'cluster' ) {
|
|
1098
|
-
|
|
1148
|
+
const clusterQuery =[
|
|
1149
|
+
{ $match: { 'Teamlead.email': { $in: inputData.RMList } } },
|
|
1150
|
+
{ $unwind: { path: '$stores', preserveNullAndEmptyArrays: true } },
|
|
1099
1151
|
{
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
trustScore: 0,
|
|
1152
|
+
$group: {
|
|
1153
|
+
_id: '$clusterName',
|
|
1154
|
+
clusterName: { $first: '$clusterName' },
|
|
1155
|
+
store: { $addToSet: '$stores.storeId' },
|
|
1156
|
+
|
|
1157
|
+
},
|
|
1107
1158
|
},
|
|
1159
|
+
{ $project: {
|
|
1160
|
+
RMName: inputData?.RMList[0],
|
|
1161
|
+
clusterName: 1,
|
|
1162
|
+
storesCount: { $size: '$store' },
|
|
1163
|
+
store: 1,
|
|
1164
|
+
} },
|
|
1165
|
+
];
|
|
1166
|
+
const getCluster = await aggregateClusters( clusterQuery );
|
|
1167
|
+
logger.info( { getCluster: getCluster } );
|
|
1168
|
+
if ( !getCluster || getCluster?.length == 0 ) {
|
|
1169
|
+
return res.sendError( 'No data', 400 );
|
|
1170
|
+
}
|
|
1171
|
+
const temp =[];
|
|
1172
|
+
for ( const [ i, cluster ] of getCluster.entries() ) {
|
|
1173
|
+
logger.info( { cluster: cluster } );
|
|
1174
|
+
temp.push( cluster );
|
|
1175
|
+
const getClusterQuery= {
|
|
1176
|
+
'size': 0,
|
|
1177
|
+
'query': {
|
|
1178
|
+
'bool': {
|
|
1179
|
+
'must': [
|
|
1180
|
+
{ 'terms': { 'storeId.keyword': cluster?.store } },
|
|
1181
|
+
{ 'term': { 'type.keyword': inputData?.type } },
|
|
1182
|
+
{
|
|
1183
|
+
'range': {
|
|
1184
|
+
'date': {
|
|
1185
|
+
'gte': inputData?.fromDate,
|
|
1186
|
+
'lte': inputData?.toDate,
|
|
1187
|
+
},
|
|
1188
|
+
},
|
|
1189
|
+
},
|
|
1108
1190
|
|
|
1109
|
-
|
|
1110
|
-
} else {
|
|
1111
|
-
return res.sendSuccess( { result: [
|
|
1112
|
-
{
|
|
1113
|
-
'fileDate': '2025-08-19',
|
|
1114
|
-
'comment': '',
|
|
1115
|
-
'subComment': '',
|
|
1116
|
-
'date': '2025-08-19T00:00:00.000+00:00',
|
|
1117
|
-
'storeName': 'LKST886',
|
|
1118
|
-
'storeId': '11-995',
|
|
1119
|
-
'type': 'physical',
|
|
1120
|
-
'optumId': '184812',
|
|
1121
|
-
'queueId': '106906147',
|
|
1122
|
-
'engagementId': '',
|
|
1123
|
-
'totalSteps': 6,
|
|
1124
|
-
'coveredStepsAI': 5,
|
|
1125
|
-
'testDuration': 420,
|
|
1126
|
-
'auditStatus': 'Yet-to-Audit',
|
|
1127
|
-
'userId': null,
|
|
1128
|
-
'visitorsType': 'adult',
|
|
1129
|
-
'inputBucketName': 'tango-eye-test-output',
|
|
1130
|
-
'filePath': 'eye-test/2025-08-19/11-995/106906147_184812.mp4',
|
|
1131
|
-
'startTime': '',
|
|
1132
|
-
'endTime': '',
|
|
1133
|
-
'displayName': '',
|
|
1134
|
-
'testStartTime': '17:13:34',
|
|
1135
|
-
'testEndTime': '17:20:34',
|
|
1136
|
-
'createdAt': '2025-08-20T08:05:28.188Z',
|
|
1137
|
-
'updatedAt': '2025-08-20T08:05:28.188Z',
|
|
1138
|
-
'steps': [
|
|
1139
|
-
{
|
|
1140
|
-
'processName': 'Distance-VA-Check',
|
|
1141
|
-
'AIStatus': true,
|
|
1142
|
-
'predictedTranscript': '',
|
|
1143
|
-
},
|
|
1144
|
-
{
|
|
1145
|
-
'processName': 'DuoChrome-Test',
|
|
1146
|
-
'AIStatus': true,
|
|
1147
|
-
'predictedTranscript': '',
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
'processName': 'Torchlight',
|
|
1151
|
-
'AIStatus': true,
|
|
1152
|
-
'predictedTranscript': '',
|
|
1191
|
+
],
|
|
1153
1192
|
},
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
'
|
|
1193
|
+
},
|
|
1194
|
+
'aggs': {
|
|
1195
|
+
'total_count': {
|
|
1196
|
+
'value_count': { 'field': '_id' },
|
|
1158
1197
|
},
|
|
1159
|
-
{
|
|
1160
|
-
'
|
|
1161
|
-
'AIStatus': true,
|
|
1162
|
-
'predictedTranscript': '',
|
|
1198
|
+
'avg_complianceScore': {
|
|
1199
|
+
'avg': { 'field': 'ComplianceScore' },
|
|
1163
1200
|
},
|
|
1164
|
-
{
|
|
1165
|
-
'
|
|
1166
|
-
'
|
|
1167
|
-
|
|
1201
|
+
'audited_trustScore': {
|
|
1202
|
+
'filter': { 'terms': { 'auditStatus.keyword': [ 'Audited', 'reAudited' ] } },
|
|
1203
|
+
'aggs': {
|
|
1204
|
+
'avg_trustScore': {
|
|
1205
|
+
'avg': { 'field': 'trustScore' },
|
|
1206
|
+
},
|
|
1207
|
+
'totalCount': {
|
|
1208
|
+
'value_count': { 'field': '_id' },
|
|
1209
|
+
},
|
|
1210
|
+
},
|
|
1168
1211
|
},
|
|
1169
|
-
|
|
1212
|
+
},
|
|
1213
|
+
};
|
|
1214
|
+
const getResponse = await getOpenSearchData( openSearch.EyeTestInput, getClusterQuery );
|
|
1215
|
+
logger.info( { getResponse: getResponse } );
|
|
1216
|
+
if ( getResponse?.body?.aggregations ) {
|
|
1217
|
+
delete temp[i].store;
|
|
1218
|
+
delete temp[i]._id;
|
|
1219
|
+
temp[i].totalFiles = getResponse?.body?.aggregations?.total_count?.value || 0,
|
|
1220
|
+
temp[i].completedFiles=getResponse?.body?.aggregations?.audited_trustScore?.totalCount?.value || 0;
|
|
1221
|
+
temp[i].complianceScore = getResponse?.body?.aggregations?.avg_complianceScore?.value || 0;
|
|
1222
|
+
temp[i].trustScore =getResponse?.body?.aggregations?.audited_trustScore?.totalCount?.value || 'NA';
|
|
1223
|
+
logger.info( { getResponse: getResponse, ms: '........1' } );
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
return res.sendSuccess( { result: temp, count: getCluster?.length || 0 } );
|
|
1228
|
+
} else {
|
|
1229
|
+
let search ={
|
|
1230
|
+
'must': filter,
|
|
1231
|
+
};
|
|
1232
|
+
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
1233
|
+
if ( inputData.type&&inputData.type==='remote' ) {
|
|
1234
|
+
search ={
|
|
1235
|
+
'must': filter,
|
|
1236
|
+
'should': [
|
|
1237
|
+
{
|
|
1238
|
+
'wildcard': {
|
|
1239
|
+
'storeName.keyword': {
|
|
1240
|
+
'value': `*${inputData.searchValue}*`,
|
|
1241
|
+
},
|
|
1242
|
+
},
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
'wildcard': {
|
|
1246
|
+
'storeId.keyword': {
|
|
1247
|
+
'value': `*${inputData.searchValue}*`,
|
|
1248
|
+
},
|
|
1249
|
+
},
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
'wildcard': {
|
|
1253
|
+
'engagementId.keyword': {
|
|
1254
|
+
'value': `*${inputData.searchValue}*`,
|
|
1255
|
+
},
|
|
1256
|
+
},
|
|
1257
|
+
},
|
|
1258
|
+
|
|
1259
|
+
{
|
|
1260
|
+
'wildcard': {
|
|
1261
|
+
'auditStatus.keyword': {
|
|
1262
|
+
'value': `*${inputData.searchValue}*`,
|
|
1263
|
+
},
|
|
1264
|
+
},
|
|
1265
|
+
},
|
|
1266
|
+
],
|
|
1267
|
+
'minimum_should_match': 1,
|
|
1268
|
+
};
|
|
1269
|
+
} else {
|
|
1270
|
+
search ={
|
|
1271
|
+
'must': filter,
|
|
1272
|
+
'should': [
|
|
1273
|
+
{
|
|
1274
|
+
'wildcard': {
|
|
1275
|
+
'storeName.keyword': {
|
|
1276
|
+
'value': `*${inputData.searchValue}*`,
|
|
1277
|
+
},
|
|
1278
|
+
},
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
'wildcard': {
|
|
1282
|
+
'storeId.keyword': {
|
|
1283
|
+
'value': `*${inputData.searchValue}*`,
|
|
1284
|
+
},
|
|
1285
|
+
},
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
'wildcard': {
|
|
1289
|
+
'engagementId.keyword': {
|
|
1290
|
+
'value': `*${inputData.searchValue}*`,
|
|
1291
|
+
},
|
|
1292
|
+
},
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
'wildcard': {
|
|
1296
|
+
'queueId.keyword': {
|
|
1297
|
+
'value': `*${inputData.searchValue}*`,
|
|
1298
|
+
},
|
|
1299
|
+
},
|
|
1300
|
+
},
|
|
1301
|
+
{
|
|
1302
|
+
'wildcard': {
|
|
1303
|
+
'optumId.keyword': {
|
|
1304
|
+
'value': `*${inputData.searchValue}*`,
|
|
1305
|
+
},
|
|
1306
|
+
},
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
'wildcard': {
|
|
1310
|
+
'visitorsType.keyword': {
|
|
1311
|
+
'value': `*${inputData.searchValue}*`,
|
|
1312
|
+
},
|
|
1313
|
+
},
|
|
1314
|
+
},
|
|
1315
|
+
|
|
1316
|
+
{
|
|
1317
|
+
'wildcard': {
|
|
1318
|
+
'auditStatus.keyword': {
|
|
1319
|
+
'value': `*${inputData.searchValue}*`,
|
|
1320
|
+
},
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1323
|
+
],
|
|
1324
|
+
'minimum_should_match': 1,
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
let searchQuery={
|
|
1330
|
+
'from': offset,
|
|
1331
|
+
'size': limit,
|
|
1332
|
+
'query': {
|
|
1333
|
+
'bool': search,
|
|
1170
1334
|
},
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
'
|
|
1179
|
-
'
|
|
1180
|
-
'
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
'
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
'userId': null,
|
|
1187
|
-
'visitorsType': 'adult',
|
|
1188
|
-
'inputBucketName': 'tango-eye-test-output',
|
|
1189
|
-
'filePath': 'eye-test/2025-08-18/11-10/106772967_164980.mp4',
|
|
1190
|
-
'startTime': '',
|
|
1191
|
-
'endTime': '',
|
|
1192
|
-
'displayName': '',
|
|
1193
|
-
'testStartTime': '12:25:32',
|
|
1194
|
-
'testEndTime': '12:35:12',
|
|
1195
|
-
'createdAt': '2025-08-19T11:56:55.822Z',
|
|
1196
|
-
'updatedAt': '2025-08-19T11:56:55.822Z',
|
|
1197
|
-
'steps': [
|
|
1198
|
-
{
|
|
1199
|
-
'processName': 'Distance-VA-Check',
|
|
1200
|
-
'AIStatus': true,
|
|
1201
|
-
'predictedTranscript': '',
|
|
1202
|
-
},
|
|
1203
|
-
{
|
|
1204
|
-
'processName': 'DuoChrome-Test',
|
|
1205
|
-
'AIStatus': true,
|
|
1206
|
-
'predictedTranscript': '',
|
|
1207
|
-
},
|
|
1208
|
-
{
|
|
1209
|
-
'processName': 'Prescription-Verification',
|
|
1210
|
-
'AIStatus': true,
|
|
1211
|
-
'predictedTranscript': '',
|
|
1212
|
-
},
|
|
1213
|
-
{
|
|
1214
|
-
'processName': 'Near-VA-Check',
|
|
1215
|
-
'AIStatus': true,
|
|
1216
|
-
'predictedTranscript': '',
|
|
1217
|
-
},
|
|
1218
|
-
{
|
|
1219
|
-
'processName': 'Torchlight',
|
|
1220
|
-
'AIStatus': false,
|
|
1221
|
-
'predictedTranscript': '',
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
'processName': 'JCC',
|
|
1225
|
-
'AIStatus': false,
|
|
1226
|
-
'predictedTranscript': '',
|
|
1227
|
-
},
|
|
1335
|
+
'sort': [
|
|
1336
|
+
{ date: { order: 'desc' } },
|
|
1337
|
+
],
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
if ( sortBy && sortBy !== '' ) {
|
|
1341
|
+
searchQuery={
|
|
1342
|
+
'from': offset,
|
|
1343
|
+
'size': limit,
|
|
1344
|
+
'query': {
|
|
1345
|
+
'bool': search,
|
|
1346
|
+
},
|
|
1347
|
+
'sort': [
|
|
1348
|
+
{ [sortBy]: { order: order === -1 ?'desc':'asc' } },
|
|
1349
|
+
{ '_id': 'asc' },
|
|
1228
1350
|
],
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
if ( inputData.isExport==true ) {
|
|
1355
|
+
searchQuery={
|
|
1356
|
+
'from': 0,
|
|
1357
|
+
'size': 10000,
|
|
1358
|
+
'query': {
|
|
1359
|
+
'bool': search,
|
|
1360
|
+
},
|
|
1361
|
+
'sort': [
|
|
1362
|
+
{ 'storeName.keyword': { order: 'desc' } },
|
|
1363
|
+
],
|
|
1364
|
+
};
|
|
1365
|
+
// allResult =await fetchAllDocuments( openSearch.EyeTestInput, search );
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
const countQuery = {
|
|
1369
|
+
query: {
|
|
1370
|
+
bool: search,
|
|
1229
1371
|
},
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
'
|
|
1313
|
-
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1374
|
+
const result = await getOpenSearchData( openSearch.EyeTestInput, searchQuery );
|
|
1375
|
+
const getCount = inputData.isExport==true? null:await getOpenSearchCount( openSearch.EyeTestInput, countQuery );
|
|
1376
|
+
const count =inputData.isExport==true?null: getCount?.body?.count;
|
|
1377
|
+
const searchValue = result?.body?.hits?.hits;
|
|
1378
|
+
const temp =[];
|
|
1379
|
+
if ( !searchValue || searchValue?.length == 0 ) {
|
|
1380
|
+
return res.sendError( 'No data found', 204 );
|
|
1381
|
+
}
|
|
1382
|
+
if ( inputData.isExport == true ) {
|
|
1383
|
+
const chunkedMappingData = await chunkArray( searchValue, 10 );
|
|
1384
|
+
const promises = chunkedMappingData.map( async ( chunk ) => {
|
|
1385
|
+
const exportData = [];
|
|
1386
|
+
for ( const element of chunk ) {
|
|
1387
|
+
const testDuration = element?._source?.testDuration;
|
|
1388
|
+
const minutes = Math.floor( testDuration / 60 );
|
|
1389
|
+
const seconds = testDuration % 60;
|
|
1390
|
+
const minutes1 =minutes> 1? `${minutes} mins` : `${minutes} min`;
|
|
1391
|
+
const seconds1 = seconds > 1? `${minutes} secs`: seconds == 1? `${minutes} sec` : '';
|
|
1392
|
+
const duration =`${minutes1} ${seconds1}`;
|
|
1393
|
+
let userName = '';
|
|
1394
|
+
if ( element?._source?.userId&&element?._source?.userId!='' ) {
|
|
1395
|
+
userName = await findOneUser( { _id: element?._source?.userId }, { _id: 0, userName: 1 } );
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
let RMName = '';
|
|
1399
|
+
let clusterName='';
|
|
1400
|
+
if ( element?._source?.storeId&&element?._source?.storeId!='' ) {
|
|
1401
|
+
const getCluster = await findOneClusters( { 'stores.storeId': element?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1402
|
+
RMName =( getCluster && getCluster.Teamlead?.length > 0 )? getCluster?.Teamlead?.[0]?.email : '';
|
|
1403
|
+
clusterName = getCluster?.clusterName;
|
|
1404
|
+
}
|
|
1405
|
+
if ( element?._source?.type == 'physical' ) {
|
|
1406
|
+
exportData.push( {
|
|
1407
|
+
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1408
|
+
'RM Name': RMName,
|
|
1409
|
+
'Cluster Name': clusterName,
|
|
1410
|
+
'Store Name': element?._source?.storeName,
|
|
1411
|
+
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
1412
|
+
'Store Name': element?._source?.storeName ||'Un Assigned',
|
|
1413
|
+
'Optum ID': element?._source?.optumId,
|
|
1414
|
+
'Queue ID': element?._source?.queueId,
|
|
1415
|
+
'Compliance Score': element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0,
|
|
1416
|
+
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1417
|
+
'Trust Score': element?._source?.trustScore || 0,
|
|
1418
|
+
'Visitor Type': element?._source?.visitorsType,
|
|
1419
|
+
'Test Duration': duration || '',
|
|
1420
|
+
'Audit Status': element?._source?.auditStatus || '',
|
|
1421
|
+
'Audited By': userName?.userName || '',
|
|
1422
|
+
|
|
1423
|
+
} );
|
|
1424
|
+
} else {
|
|
1425
|
+
exportData.push( {
|
|
1426
|
+
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1427
|
+
'Cluster Name': clusterName,
|
|
1428
|
+
'Store Name': element?._source?.storeName,
|
|
1429
|
+
'Store Name': element?._source?.storeName,
|
|
1430
|
+
'Store ID': element?._source?.storeId || 'Un Assigned',
|
|
1431
|
+
'Store Name': element?._source?.storeName ||'Un Assigned',
|
|
1432
|
+
'Engagement ID': element?._source?.engagementId,
|
|
1433
|
+
'Compliance Score': element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0,
|
|
1434
|
+
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1435
|
+
'Trust Score': element?._source?.trustScore ||0,
|
|
1436
|
+
'Test Duration': duration || '',
|
|
1437
|
+
'Audit Status': element?._source?.auditStatus || '',
|
|
1438
|
+
'Audited By': userName?.userName || '',
|
|
1439
|
+
|
|
1440
|
+
} );
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return exportData;
|
|
1444
|
+
} );
|
|
1445
|
+
const mappedArrays = await Promise.all( promises );
|
|
1446
|
+
const result = mappedArrays.flat();
|
|
1447
|
+
await download( result, res );
|
|
1448
|
+
return;
|
|
1449
|
+
} else {
|
|
1450
|
+
for ( const [ i, item ] of searchValue.entries() ) {
|
|
1451
|
+
temp.push( item?._source );
|
|
1452
|
+
logger.info( { source: item } );
|
|
1453
|
+
let userName='';
|
|
1454
|
+
if ( item?._source?.userId&&item?._source?.userId!='' ) {
|
|
1455
|
+
userName = await findOneUser( { _id: item?._source?.userId }, { _id: 0, userName: 1 } );
|
|
1456
|
+
}
|
|
1457
|
+
let RMName = '';
|
|
1458
|
+
let clusterName='';
|
|
1459
|
+
if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
|
|
1460
|
+
const getCluster = await findOneClusters( { 'stores.storeId': item?._source?.storeId }, { Teamlead: 1, clusterName: 1 } );
|
|
1461
|
+
RMName =( getCluster && getCluster.Teamlead?.length > 0 )? getCluster?.Teamlead?.[0]?.email : '';
|
|
1462
|
+
clusterName = getCluster?.clusterName;
|
|
1463
|
+
}
|
|
1464
|
+
logger.info( { RMName: RMName } );
|
|
1465
|
+
const testDuration = item?._source?.testDuration;
|
|
1466
|
+
const minutes = Math.floor( testDuration / 60 );
|
|
1467
|
+
const seconds = testDuration % 60;
|
|
1468
|
+
temp[i].complianceScore = item?._source?.totalSteps>0 ? Math.round( ( item?._source?.coveredStepsAI/ item?._source?.totalSteps )*100 ): 0;
|
|
1469
|
+
temp[i].min = minutes;
|
|
1470
|
+
temp[i].sec = seconds;
|
|
1471
|
+
temp[i].auditedBy = userName?.userName || '';
|
|
1472
|
+
temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
|
|
1473
|
+
temp[i].RMName = RMName;
|
|
1474
|
+
temp[i].clusterName =clusterName;
|
|
1475
|
+
}
|
|
1476
|
+
logger.info( { temp: temp } );
|
|
1477
|
+
}
|
|
1314
1478
|
|
|
1315
|
-
|
|
1479
|
+
return res.sendSuccess( { result: temp, count: count } );
|
|
1316
1480
|
}
|
|
1317
1481
|
} catch ( error ) {
|
|
1318
1482
|
const err = error.message || 'Internal Server Error';
|
|
@@ -5,6 +5,10 @@ export function aggregateClusters( query ) {
|
|
|
5
5
|
return clusterModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export function findClusters( query ) {
|
|
8
|
+
export function findClusters( query, field ) {
|
|
9
9
|
return clusterModel.find( query, field );
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
export function findOneClusters( query, field ) {
|
|
13
|
+
return clusterModel.findOne( query, field ).sort( { _id: -1 } );
|
|
14
|
+
}
|