tango-app-api-audit 3.6.19 → 3.6.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
|
@@ -637,6 +637,9 @@ export async function getAuditFile( req, res ) {
|
|
|
637
637
|
'minimum_should_match': 1,
|
|
638
638
|
},
|
|
639
639
|
},
|
|
640
|
+
sort: [
|
|
641
|
+
{ timestamp: { order: 'desc' } },
|
|
642
|
+
],
|
|
640
643
|
|
|
641
644
|
}:
|
|
642
645
|
{
|
|
@@ -664,6 +667,9 @@ export async function getAuditFile( req, res ) {
|
|
|
664
667
|
],
|
|
665
668
|
},
|
|
666
669
|
},
|
|
670
|
+
sort: [
|
|
671
|
+
{ timestamp: { order: 'desc' } },
|
|
672
|
+
],
|
|
667
673
|
|
|
668
674
|
};
|
|
669
675
|
logger.info( { fetchData: fetchData, msg: msg, inputData: inputData, type: 'debug-bucketNameIssue' } );
|
|
@@ -847,6 +853,7 @@ export async function getAuditFile( req, res ) {
|
|
|
847
853
|
storeId: storeId,
|
|
848
854
|
storeName: storeInfo?.storeName,
|
|
849
855
|
address: storeInfo?.address,
|
|
856
|
+
folderPath: folderPath,
|
|
850
857
|
file: {
|
|
851
858
|
queueName: inputData.queueName,
|
|
852
859
|
store_id: storeId,
|
|
@@ -4507,6 +4514,9 @@ export async function auditImages( req, res ) {
|
|
|
4507
4514
|
},
|
|
4508
4515
|
},
|
|
4509
4516
|
|
|
4517
|
+
sort: [
|
|
4518
|
+
{ timestamp: { order: 'desc' } },
|
|
4519
|
+
],
|
|
4510
4520
|
};
|
|
4511
4521
|
const files = [];
|
|
4512
4522
|
const list = await searchOpenSearchData( openSearch.trackerInput, getQuery );
|
|
@@ -4583,6 +4593,9 @@ export async function auditImages( req, res ) {
|
|
|
4583
4593
|
'minimum_should_match': 1,
|
|
4584
4594
|
},
|
|
4585
4595
|
},
|
|
4596
|
+
sort: [
|
|
4597
|
+
{ timestamp: { order: 'desc' } },
|
|
4598
|
+
],
|
|
4586
4599
|
|
|
4587
4600
|
};
|
|
4588
4601
|
const filesAC = [];
|
|
@@ -811,6 +811,7 @@ export async function save( req, res ) {
|
|
|
811
811
|
},
|
|
812
812
|
};
|
|
813
813
|
const getOutput = await getOpenSearchData( openSearch.EyeTestOutput, searchQuery );
|
|
814
|
+
logger.info( { getOutput: getOutput } );
|
|
814
815
|
const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
|
|
815
816
|
if ( !output ) {
|
|
816
817
|
return res.sendError( 'This file is currently being audited by another user. Any actions you perform will not be saved.', 400 );
|
|
@@ -844,27 +845,19 @@ export async function save( req, res ) {
|
|
|
844
845
|
|
|
845
846
|
const getEyetestConfig = await findOneEyeTestConfig( { clientId: req?.user.userType == 'tango'? inputData?.clientId : req.user.clientId, configureType: 'email' }, { complianceThreshold: 1 } );
|
|
846
847
|
|
|
847
|
-
if ( getEyetestConfig &&
|
|
848
|
+
if ( getEyetestConfig && inputData.auditStatus == 'Audited' && inputUpdatedData ) {
|
|
848
849
|
const trustScore = Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) );
|
|
849
850
|
const value = Number( getEyetestConfig?.complianceThreshold?.value?.split( '%' )[0] );
|
|
850
851
|
const condition = getEyetestConfig?.complianceThreshold?.condition;
|
|
851
|
-
const id=
|
|
852
|
-
const humanScore = Math.round( ( inputUpdatedData?._source?.auditedSteps /inputUpdatedData?._source?.totalSteps ) * 100 );
|
|
853
|
-
const userName = await findOneUser( { _id: new mongoose.Types.ObjectId( inputUpdatedData?._source?.userId ) }, { userName: 1 } );
|
|
854
|
-
|
|
855
|
-
|
|
852
|
+
const id= `${inputData?.RMEmail}_${inputData?.cluster}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}`;
|
|
856
853
|
switch ( condition ) {
|
|
857
854
|
case '>': if ( trustScore > value ) {
|
|
858
855
|
const record1 = {
|
|
859
856
|
RMEmail: inputData.RMEmail,
|
|
860
|
-
RMName: inputData.RMEmail,
|
|
861
857
|
cluster: inputData.cluster,
|
|
862
858
|
optumId: inputUpdatedData?._source?.optumId,
|
|
863
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
864
859
|
storeName: inputUpdatedData?._source?.storeName,
|
|
865
860
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
866
|
-
humanScore: humanScore,
|
|
867
|
-
auditedBy: userName?.userName || '',
|
|
868
861
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
869
862
|
auditedId: inputUpdatedData?._id,
|
|
870
863
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -878,14 +871,10 @@ export async function save( req, res ) {
|
|
|
878
871
|
case '<': if ( trustScore < value ) {
|
|
879
872
|
const record2 = {
|
|
880
873
|
RMEmail: inputData.RMEmail,
|
|
881
|
-
RMName: inputData.RMEmail,
|
|
882
874
|
cluster: inputData.cluster,
|
|
883
875
|
optumId: inputUpdatedData?._source?.optumId,
|
|
884
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
885
876
|
storeName: inputUpdatedData?._source?.storeName,
|
|
886
877
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
887
|
-
humanScore: humanScore,
|
|
888
|
-
auditedBy: userName?.userName || '',
|
|
889
878
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
890
879
|
auditedId: inputUpdatedData?._id,
|
|
891
880
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -899,14 +888,10 @@ export async function save( req, res ) {
|
|
|
899
888
|
case '>=': if ( trustScore >= value ) {
|
|
900
889
|
const record3 = {
|
|
901
890
|
RMEmail: inputData.RMEmail,
|
|
902
|
-
RMName: inputData.RMEmail,
|
|
903
891
|
cluster: inputData.cluster,
|
|
904
892
|
optumId: inputUpdatedData?._source?.optumId,
|
|
905
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
906
893
|
storeName: inputUpdatedData?._source?.storeName,
|
|
907
894
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
908
|
-
humanScore: humanScore,
|
|
909
|
-
auditedBy: userName?.userName || '',
|
|
910
895
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
911
896
|
auditedId: inputUpdatedData?._id,
|
|
912
897
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -920,14 +905,10 @@ export async function save( req, res ) {
|
|
|
920
905
|
case '<=': if ( trustScore <= value ) {
|
|
921
906
|
const record4 = {
|
|
922
907
|
RMEmail: inputData.RMEmail,
|
|
923
|
-
RMName: inputData.RMEmail,
|
|
924
908
|
cluster: inputData.cluster,
|
|
925
909
|
optumId: inputUpdatedData?._source?.optumId,
|
|
926
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
927
910
|
storeName: inputUpdatedData?._source?.storeName,
|
|
928
911
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
929
|
-
humanScore: humanScore,
|
|
930
|
-
auditedBy: userName?.userName || '',
|
|
931
912
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
932
913
|
auditedId: inputUpdatedData?._id,
|
|
933
914
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -942,14 +923,10 @@ export async function save( req, res ) {
|
|
|
942
923
|
case '==': if ( trustScore == value ) {
|
|
943
924
|
const record5 = {
|
|
944
925
|
RMEmail: inputData.RMEmail,
|
|
945
|
-
RMName: inputData.RMEmail,
|
|
946
926
|
cluster: inputData.cluster,
|
|
947
927
|
optumId: inputUpdatedData?._source?.optumId,
|
|
948
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
949
928
|
storeName: inputUpdatedData?._source?.storeName,
|
|
950
929
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
951
|
-
humanScore: humanScore,
|
|
952
|
-
auditedBy: userName?.userName || '',
|
|
953
930
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
954
931
|
auditedId: inputUpdatedData?._id,
|
|
955
932
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -963,14 +940,10 @@ export async function save( req, res ) {
|
|
|
963
940
|
case '===': if ( trustScore === value ) {
|
|
964
941
|
const record6 = {
|
|
965
942
|
RMEmail: inputData.RMEmail,
|
|
966
|
-
RMName: inputData.RMEmail,
|
|
967
943
|
cluster: inputData.cluster,
|
|
968
944
|
optumId: inputUpdatedData?._source?.optumId,
|
|
969
|
-
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
970
945
|
storeName: inputUpdatedData?._source?.storeName,
|
|
971
946
|
complianceScore: inputUpdatedData?._source?.ComplianceScore,
|
|
972
|
-
humanScore: humanScore,
|
|
973
|
-
auditedBy: userName?.userName || '',
|
|
974
947
|
trustScore: inputUpdatedData?._source?.trustScore,
|
|
975
948
|
auditedId: inputUpdatedData?._id,
|
|
976
949
|
queueId: inputUpdatedData?._source?.queueId,
|
|
@@ -983,7 +956,7 @@ export async function save( req, res ) {
|
|
|
983
956
|
default: throw new Error( `Unknown condition: ${condition}` );
|
|
984
957
|
}
|
|
985
958
|
}
|
|
986
|
-
return res.sendSuccess( 'The file has been
|
|
959
|
+
return res.sendSuccess( 'The file has been submited successfully' );
|
|
987
960
|
} catch ( error ) {
|
|
988
961
|
const err = error.message || 'Internal Server Error';
|
|
989
962
|
logger.error( { message: error, data: req.params, function: 'eyetestAudit-controller-save' } );
|
|
@@ -1225,25 +1198,18 @@ export async function userAuditedData( req, res ) {
|
|
|
1225
1198
|
|
|
1226
1199
|
export async function summaryList( req, res ) {
|
|
1227
1200
|
try {
|
|
1228
|
-
// declare inputData and get request body
|
|
1229
1201
|
const inputData = req.body;
|
|
1230
|
-
|
|
1231
|
-
// throw 204 if client id is not 11
|
|
1232
1202
|
if ( inputData.clientId !== '11' ) {
|
|
1233
1203
|
return res.sendError( 'No data found', 204 );
|
|
1234
1204
|
}
|
|
1235
1205
|
|
|
1236
|
-
// declare openSearch and get data form the .env/secret manager
|
|
1237
1206
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1238
|
-
|
|
1239
|
-
// set limit, offset, sortBy, sortOrder value if not set default value
|
|
1240
1207
|
const limit = inputData.limit || 10;
|
|
1241
1208
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1242
1209
|
|
|
1243
1210
|
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date', 'ComplianceScore', 'auditedSteps' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1244
1211
|
const order = inputData?.sortOrder || -1;
|
|
1245
1212
|
|
|
1246
|
-
// declare filter and assign range values from inputData
|
|
1247
1213
|
let filter= [
|
|
1248
1214
|
{
|
|
1249
1215
|
'range': {
|
|
@@ -1256,7 +1222,6 @@ export async function summaryList( req, res ) {
|
|
|
1256
1222
|
|
|
1257
1223
|
];
|
|
1258
1224
|
|
|
1259
|
-
// filter by Audit Status if key has minimum one element
|
|
1260
1225
|
if ( inputData?.auditStatus && inputData?.auditStatus?.length > 0 ) {
|
|
1261
1226
|
filter.push( {
|
|
1262
1227
|
'terms': {
|
|
@@ -1264,8 +1229,6 @@ export async function summaryList( req, res ) {
|
|
|
1264
1229
|
},
|
|
1265
1230
|
} );
|
|
1266
1231
|
}
|
|
1267
|
-
|
|
1268
|
-
// filter by Visitors Type if key has minimum one element
|
|
1269
1232
|
if ( inputData?.demographics && inputData?.demographics?.length > 0 ) {
|
|
1270
1233
|
filter.push( {
|
|
1271
1234
|
'terms': {
|
|
@@ -1273,8 +1236,6 @@ export async function summaryList( req, res ) {
|
|
|
1273
1236
|
},
|
|
1274
1237
|
} );
|
|
1275
1238
|
}
|
|
1276
|
-
|
|
1277
|
-
// filter by Eye test Type if key has string value one element
|
|
1278
1239
|
if ( inputData.type && inputData.type!='' ) {
|
|
1279
1240
|
filter.push( {
|
|
1280
1241
|
'term': {
|
|
@@ -1284,17 +1245,6 @@ export async function summaryList( req, res ) {
|
|
|
1284
1245
|
} );
|
|
1285
1246
|
}
|
|
1286
1247
|
|
|
1287
|
-
// filter by near addition if value != "" and eye test must be a physical
|
|
1288
|
-
if ( inputData.nearAddition && inputData.nearAddition!='' && inputData.type ==='physical' ) {
|
|
1289
|
-
filter.push( {
|
|
1290
|
-
'term': {
|
|
1291
|
-
'nearAddition.keyword': inputData.nearAddition,
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
} );
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
// filter by stores if key has minimum one element else throw an error
|
|
1298
1248
|
if ( inputData.storeId && inputData.storeId.length > 0 ) {
|
|
1299
1249
|
filter.push( {
|
|
1300
1250
|
|
|
@@ -1303,20 +1253,15 @@ export async function summaryList( req, res ) {
|
|
|
1303
1253
|
},
|
|
1304
1254
|
|
|
1305
1255
|
} );
|
|
1306
|
-
}
|
|
1307
|
-
else {
|
|
1256
|
+
} else {
|
|
1308
1257
|
return res.sendError( 'No data found', 204 );
|
|
1309
1258
|
}
|
|
1310
1259
|
|
|
1311
|
-
// Declare mustQuery as an array and include all elements from the filter array
|
|
1312
1260
|
let mustQuery = [
|
|
1313
1261
|
...filter,
|
|
1314
1262
|
];
|
|
1315
1263
|
|
|
1316
|
-
|
|
1317
|
-
if ( inputData.complianceScore && inputData.complianceScore?.length > 0 ) {
|
|
1318
|
-
|
|
1319
|
-
// If the key type is not 'store', split the compliance score ranges
|
|
1264
|
+
if ( inputData.complianceScore && inputData.complianceScore?.length > null ) {
|
|
1320
1265
|
if ( inputData.keyType !== 'store' ) {
|
|
1321
1266
|
const rangeShould = inputData?.complianceScore?.map( ( r ) => {
|
|
1322
1267
|
const [ gte, lte ] = r.split( '-' ).map( Number );
|
|
@@ -1326,7 +1271,7 @@ export async function summaryList( req, res ) {
|
|
|
1326
1271
|
},
|
|
1327
1272
|
};
|
|
1328
1273
|
} );
|
|
1329
|
-
|
|
1274
|
+
|
|
1330
1275
|
mustQuery.push(
|
|
1331
1276
|
{
|
|
1332
1277
|
bool: {
|
|
@@ -1335,9 +1280,7 @@ export async function summaryList( req, res ) {
|
|
|
1335
1280
|
},
|
|
1336
1281
|
},
|
|
1337
1282
|
);
|
|
1338
|
-
}
|
|
1339
|
-
// If-else condition: use 'terms' filter to match records by Compliance Score / Tango Score
|
|
1340
|
-
else {
|
|
1283
|
+
} else {
|
|
1341
1284
|
const values = Array.isArray( inputData.complianceScore ) ?
|
|
1342
1285
|
inputData.complianceScore.map( Number ) :
|
|
1343
1286
|
[ Number( inputData.complianceScore ) ];
|
|
@@ -1350,7 +1293,6 @@ export async function summaryList( req, res ) {
|
|
|
1350
1293
|
}
|
|
1351
1294
|
}
|
|
1352
1295
|
|
|
1353
|
-
// filter by category if key exist allow "fake, genuine" else throw valid category
|
|
1354
1296
|
if ( inputData?.category ) {
|
|
1355
1297
|
switch ( inputData?.category ) {
|
|
1356
1298
|
case 'fake':
|
|
@@ -2176,15 +2118,6 @@ export async function summaryCard( req, res ) {
|
|
|
2176
2118
|
},
|
|
2177
2119
|
} );
|
|
2178
2120
|
}
|
|
2179
|
-
|
|
2180
|
-
if ( inputData.nearAddition && inputData.nearAddition!='' && inputData.type ==='physical' ) {
|
|
2181
|
-
filter.push( {
|
|
2182
|
-
'term': {
|
|
2183
|
-
'nearAddition.keyword': inputData.nearAddition,
|
|
2184
|
-
},
|
|
2185
|
-
|
|
2186
|
-
} );
|
|
2187
|
-
}
|
|
2188
2121
|
let mustQuery = [
|
|
2189
2122
|
...filter,
|
|
2190
2123
|
];
|
|
@@ -2453,7 +2386,7 @@ export async function emailAlertLog( req, res ) {
|
|
|
2453
2386
|
inputData.clientId = req.user.userType == 'tango'? inputData?.clientId : req?.user?.clientId;
|
|
2454
2387
|
// get openserach name form the env file
|
|
2455
2388
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2456
|
-
|
|
2389
|
+
|
|
2457
2390
|
|
|
2458
2391
|
let filter =[
|
|
2459
2392
|
{
|
|
@@ -2466,7 +2399,7 @@ export async function emailAlertLog( req, res ) {
|
|
|
2466
2399
|
},
|
|
2467
2400
|
];
|
|
2468
2401
|
let sort =[
|
|
2469
|
-
{ [sortBy]: { order: inputData.sortOrder === 1 ? 'asc' : 'desc' } },
|
|
2402
|
+
{ [inputData?.sortBy]: { order: inputData.sortOrder === 1 ? 'asc' : 'desc' } },
|
|
2470
2403
|
];
|
|
2471
2404
|
if ( inputData.RmList && inputData.RmList?.lenght > 0 ) {
|
|
2472
2405
|
filter.push( {
|
|
@@ -2483,86 +2416,19 @@ export async function emailAlertLog( req, res ) {
|
|
|
2483
2416
|
},
|
|
2484
2417
|
} );
|
|
2485
2418
|
}
|
|
2486
|
-
let search = {
|
|
2487
|
-
must: filter,
|
|
2488
|
-
};
|
|
2489
|
-
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
2490
|
-
search ={
|
|
2491
|
-
'must': filter,
|
|
2492
|
-
'should': [
|
|
2493
|
-
{
|
|
2494
|
-
'wildcard': {
|
|
2495
|
-
'RMEmail.keyword': {
|
|
2496
|
-
'value': `*${inputData.searchValue}*`,
|
|
2497
|
-
},
|
|
2498
|
-
},
|
|
2499
|
-
},
|
|
2500
|
-
{
|
|
2501
|
-
'wildcard': {
|
|
2502
|
-
'RMName.keyword': {
|
|
2503
|
-
'value': `*${inputData.searchValue}*`,
|
|
2504
|
-
},
|
|
2505
|
-
},
|
|
2506
|
-
},
|
|
2507
|
-
{
|
|
2508
|
-
'wildcard': {
|
|
2509
|
-
'cluster.keyword': {
|
|
2510
|
-
'value': `*${inputData.searchValue}*`,
|
|
2511
|
-
},
|
|
2512
|
-
},
|
|
2513
|
-
},
|
|
2514
|
-
{
|
|
2515
|
-
'wildcard': {
|
|
2516
|
-
'optumId.keyword': {
|
|
2517
|
-
'value': `*${inputData.searchValue}*`,
|
|
2518
|
-
},
|
|
2519
|
-
},
|
|
2520
|
-
},
|
|
2521
|
-
{
|
|
2522
|
-
'wildcard': {
|
|
2523
|
-
'queueId.keyword': {
|
|
2524
|
-
'value': `*${inputData.searchValue}*`,
|
|
2525
|
-
},
|
|
2526
|
-
},
|
|
2527
|
-
},
|
|
2528
|
-
{
|
|
2529
|
-
'wildcard': {
|
|
2530
|
-
'storeName.keyword': {
|
|
2531
|
-
'value': `*${inputData.searchValue}*`,
|
|
2532
|
-
},
|
|
2533
|
-
},
|
|
2534
|
-
},
|
|
2535
|
-
{
|
|
2536
|
-
'wildcard': {
|
|
2537
|
-
'auditedBy.keyword': {
|
|
2538
|
-
'value': `*${inputData.searchValue}*`,
|
|
2539
|
-
},
|
|
2540
|
-
},
|
|
2541
|
-
},
|
|
2542
|
-
{
|
|
2543
|
-
'wildcard': {
|
|
2544
|
-
'optomEmailId.keyword': {
|
|
2545
|
-
'value': `*${inputData.searchValue}*`,
|
|
2546
|
-
},
|
|
2547
|
-
},
|
|
2548
|
-
},
|
|
2549
|
-
],
|
|
2550
|
-
'minimum_should_match': 1,
|
|
2551
|
-
};
|
|
2552
|
-
}
|
|
2553
2419
|
const getQuery = {
|
|
2554
2420
|
'size': inputData.isExport == true? 50000 : inputData?.limit || 10,
|
|
2555
2421
|
'from': offset || 0,
|
|
2556
2422
|
'query': {
|
|
2557
|
-
'bool':
|
|
2423
|
+
'bool': {
|
|
2424
|
+
'must': filter,
|
|
2425
|
+
},
|
|
2558
2426
|
},
|
|
2559
2427
|
'sort': sort,
|
|
2560
2428
|
};
|
|
2561
2429
|
|
|
2562
|
-
|
|
2563
2430
|
// get query result from the open saerch
|
|
2564
2431
|
const getData= await getOpenSearchData( openSearch.eyeTestEmailAlert, getQuery );
|
|
2565
|
-
const count = getData?.body?.hits?.total?.value;
|
|
2566
2432
|
// throw error if got null or empty array
|
|
2567
2433
|
if ( !getData || getData?.body?.hits?.hits?.length == 0 ) {
|
|
2568
2434
|
return res.sendError( 'No records found', 204 );
|
|
@@ -2611,7 +2477,7 @@ export async function emailAlertLog( req, res ) {
|
|
|
2611
2477
|
|
|
2612
2478
|
|
|
2613
2479
|
logger.info( { inputData: inputData, getData: response } );
|
|
2614
|
-
return res.sendSuccess( { result: response, count:
|
|
2480
|
+
return res.sendSuccess( { result: response, count: response.length } );
|
|
2615
2481
|
} catch ( error ) {
|
|
2616
2482
|
const err = error.message || 'Internal Server Error';
|
|
2617
2483
|
logger.error( { message: error, data: req.body, function: 'eyetestAudit-controller-emailAlertLog' } );
|
|
@@ -2771,6 +2637,10 @@ export async function getEmailConfig( req, res ) {
|
|
|
2771
2637
|
configureType: 'email',
|
|
2772
2638
|
};
|
|
2773
2639
|
const getOne = await findOneEyeTestConfig( query, { complianceThreshold: 1, _id: 1 } );
|
|
2640
|
+
logger.info( { getOne: getOne, message: 'getEmailConfig' } );
|
|
2641
|
+
// if ( !getOne?.complianceThreshold ) {
|
|
2642
|
+
// return res.sendError( 'No data found', 204 );
|
|
2643
|
+
// }
|
|
2774
2644
|
if ( !getOne ) {
|
|
2775
2645
|
return res.sendError( ' No data found', 204 );
|
|
2776
2646
|
}
|
|
@@ -64,7 +64,6 @@ export const saveSchema = joi.object( {
|
|
|
64
64
|
spokenLanguage: joi.string().optional(),
|
|
65
65
|
cluster: joi.string().required().allow( '' ),
|
|
66
66
|
RMEmail: joi.string().required().allow( '' ),
|
|
67
|
-
isReSend: joi.boolean().optional(),
|
|
68
67
|
} );
|
|
69
68
|
|
|
70
69
|
export const saveValid = {
|
|
@@ -157,7 +156,7 @@ export const summaryListSchema = joi.object( {
|
|
|
157
156
|
).optional(),
|
|
158
157
|
storeId: joi.array().items( joi.string().required() ).required(),
|
|
159
158
|
complianceScore: joi.array().items( joi.string().required() ).optional(),
|
|
160
|
-
nearAddition: joi.string().optional().allow( ''
|
|
159
|
+
nearAddition: joi.string().optional().allow( '' ),
|
|
161
160
|
isExport: joi.boolean().optional(),
|
|
162
161
|
searchValue: joi.string().optional().allow( '' ),
|
|
163
162
|
sortBy: joi.string().optional(),
|
|
@@ -235,7 +234,7 @@ export const summaryCardSchema = joi.object( {
|
|
|
235
234
|
).optional(),
|
|
236
235
|
storeId: joi.array().items( joi.string().required() ).required(),
|
|
237
236
|
complianceScore: joi.array().items( joi.string().required() ).optional(),
|
|
238
|
-
nearAddition: joi.string().optional().allow( ''
|
|
237
|
+
nearAddition: joi.string().optional().allow( '' ),
|
|
239
238
|
category: joi.string().optional() .valid( 'fake', 'genuine' ),
|
|
240
239
|
} );
|
|
241
240
|
|
|
@@ -280,8 +279,12 @@ export const emailAlertLogSchema = joi.object( {
|
|
|
280
279
|
|
|
281
280
|
return value;
|
|
282
281
|
} ),
|
|
282
|
+
type: joi.string().required().messages( {
|
|
283
|
+
'any.required': 'Type is required',
|
|
284
|
+
'string.empty': 'Type cannot be empty',
|
|
285
|
+
} ),
|
|
283
286
|
RMList: joi.array().items(
|
|
284
|
-
joi.string().
|
|
287
|
+
joi.string().optional(),
|
|
285
288
|
).optional(),
|
|
286
289
|
clientId: joi.string().when( '$userType', {
|
|
287
290
|
is: 'tango',
|
|
@@ -291,7 +294,7 @@ export const emailAlertLogSchema = joi.object( {
|
|
|
291
294
|
} ),
|
|
292
295
|
otherwise: joi.optional(),
|
|
293
296
|
} ),
|
|
294
|
-
cluster: joi.array().items( joi.string().required() ).
|
|
297
|
+
cluster: joi.array().items( joi.string().required() ).required(),
|
|
295
298
|
isExport: joi.boolean().optional(),
|
|
296
299
|
searchValue: joi.string().optional().allow( '' ),
|
|
297
300
|
sortBy: joi.string().optional(),
|
|
@@ -410,7 +413,6 @@ export const getEmailConfigSchema = joi.object( {
|
|
|
410
413
|
} ),
|
|
411
414
|
otherwise: joi.optional(),
|
|
412
415
|
} ),
|
|
413
|
-
|
|
414
416
|
} );
|
|
415
417
|
|
|
416
418
|
export const getEmailConfigValid = {
|
|
@@ -3,14 +3,14 @@ import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
|
3
3
|
import { accessVerification } from 'tango-app-api-middleware';
|
|
4
4
|
import { cancelValid, clusterListValid, emailAlertLogValid, getEmailConfigValid, getFileHistoryValid, getFileValid, getListValid, getUserConfigValid, rmListValid, saveValid, summaryCardValid, summaryListValid, updateEmailConfigValid, updateUserConfigValid, userAuditedDataValid, viewFileValid } from '../dtos/eyeTestAudit.dtos.js';
|
|
5
5
|
import { addUserConfig, cancel, clusterList, emailAlertLog, getEmailConfig, getFile, getFileHistory, getList, getUserConfig, rmList, save, summaryCard, summaryList, updateEmailConfig, updateEmailConfig1, updateUserConfig, userAuditedData, viewFile } from '../controllers/eyeTestAudit.controllers.js';
|
|
6
|
-
import { isSuperAdmin, roleValidation
|
|
6
|
+
import { isSuperAdmin, roleValidation } from '../validation/eyeTest.validation.js';
|
|
7
7
|
|
|
8
8
|
export const eyeTestAuditRouter = Router();
|
|
9
9
|
|
|
10
10
|
eyeTestAuditRouter.post( '/get-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getListValid ), getList );
|
|
11
11
|
eyeTestAuditRouter.get( '/view-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( viewFileValid ), viewFile );
|
|
12
12
|
eyeTestAuditRouter.get( '/get-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileValid ), getFile );
|
|
13
|
-
eyeTestAuditRouter.post( '/save', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( saveValid ),
|
|
13
|
+
eyeTestAuditRouter.post( '/save', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( saveValid ), save );
|
|
14
14
|
eyeTestAuditRouter.post( '/cancel', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( cancelValid ), cancel );
|
|
15
15
|
eyeTestAuditRouter.get( '/get-file-history/:id/:type', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileHistoryValid ), getFileHistory );
|
|
16
16
|
eyeTestAuditRouter.get( '/user-audited-data/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( userAuditedDataValid ), userAuditedData );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
2
|
|
|
3
3
|
export async function roleValidation( req, res, next ) {
|
|
4
4
|
try {
|
|
@@ -39,26 +39,3 @@ export async function isSuperAdmin( req, res, next ) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export async function sendAlert( req, res, next ) {
|
|
43
|
-
try {
|
|
44
|
-
const inputData = req.body;
|
|
45
|
-
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
46
|
-
if ( inputData.auditStatus == 'ReAudited' && inputData.type == 'physical' && inputData?.isReSend == undefined ) {
|
|
47
|
-
const getOne = await getOpenSearchById( openSearch.EyeTestInput, inputData.id );
|
|
48
|
-
const id = `${inputData.id}_${getOne?.body?._source?.optumId}_${inputData.fileId}`;
|
|
49
|
-
const getId = await getOpenSearchById( openSearch.eyeTestEmailAlert, id );
|
|
50
|
-
const inputUpdatedData = getId?.body;
|
|
51
|
-
if ( inputUpdatedData ) {
|
|
52
|
-
return res.sendError( 'Do you want resend mail?', 202 );
|
|
53
|
-
} else {
|
|
54
|
-
return next();
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
return next();
|
|
58
|
-
}
|
|
59
|
-
} catch ( error ) {
|
|
60
|
-
const err = error.message;
|
|
61
|
-
return res.sendError( err, 500 );
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|