tango-app-api-audit 3.6.28 → 3.6.30
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
|
@@ -853,6 +853,37 @@ export async function save( req, res ) {
|
|
|
853
853
|
const id= inputData?.isReSend === true ?`${inputData.id}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}_${Date.now()}` : `${inputData.id}_${inputUpdatedData?._source?.optumId}_${inputData?.fileId}`;
|
|
854
854
|
const humanScore = Math.round( ( inputUpdatedData?._source?.auditedSteps /inputUpdatedData?._source?.totalSteps ) * 100 );
|
|
855
855
|
const userName = await findOneUser( { _id: new mongoose.Types.ObjectId( inputUpdatedData?._source?.userId ) }, { userName: 1 } );
|
|
856
|
+
const emailList = inputData?.RMEmail?.split( ',' );
|
|
857
|
+
let rmName;
|
|
858
|
+
|
|
859
|
+
if ( emailList?.length > 0 ) {
|
|
860
|
+
const userQuery = [
|
|
861
|
+
{
|
|
862
|
+
$match: {
|
|
863
|
+
$and: [
|
|
864
|
+
{
|
|
865
|
+
email: { $in: emailList },
|
|
866
|
+
},
|
|
867
|
+
],
|
|
868
|
+
},
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
$group: {
|
|
872
|
+
_id: null,
|
|
873
|
+
userList: { $addToSet: '$userName' },
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
$project: {
|
|
878
|
+
userList: 1,
|
|
879
|
+
_id: 0,
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
];
|
|
883
|
+
const getRMName = await aggregateUser( userQuery );
|
|
884
|
+
rmName = getRMName?.[0]?.userList || '';
|
|
885
|
+
}
|
|
886
|
+
|
|
856
887
|
const order = [
|
|
857
888
|
'Distance-VA-Check',
|
|
858
889
|
'Torchlight Check',
|
|
@@ -878,7 +909,7 @@ export async function save( req, res ) {
|
|
|
878
909
|
case '>': if ( humanScore > value ) {
|
|
879
910
|
const record1 = {
|
|
880
911
|
RMEmail: inputData.RMEmail,
|
|
881
|
-
RMName:
|
|
912
|
+
RMName: rmName.toString(),
|
|
882
913
|
cluster: inputData.cluster,
|
|
883
914
|
optumId: inputUpdatedData?._source?.optumId,
|
|
884
915
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -909,7 +940,7 @@ export async function save( req, res ) {
|
|
|
909
940
|
case '<': if ( humanScore < value ) {
|
|
910
941
|
const record2 = {
|
|
911
942
|
RMEmail: inputData.RMEmail,
|
|
912
|
-
RMName:
|
|
943
|
+
RMName: rmName.toString(),
|
|
913
944
|
cluster: inputData.cluster,
|
|
914
945
|
optumId: inputUpdatedData?._source?.optumId,
|
|
915
946
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -940,7 +971,7 @@ export async function save( req, res ) {
|
|
|
940
971
|
case '>=': if ( humanScore >= value ) {
|
|
941
972
|
const record3 = {
|
|
942
973
|
RMEmail: inputData.RMEmail,
|
|
943
|
-
RMName:
|
|
974
|
+
RMName: rmName.toString(),
|
|
944
975
|
cluster: inputData.cluster,
|
|
945
976
|
optumId: inputUpdatedData?._source?.optumId,
|
|
946
977
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -971,7 +1002,7 @@ export async function save( req, res ) {
|
|
|
971
1002
|
case '<=': if ( humanScore <= value ) {
|
|
972
1003
|
const record4 = {
|
|
973
1004
|
RMEmail: inputData.RMEmail,
|
|
974
|
-
RMName:
|
|
1005
|
+
RMName: rmName.toString(),
|
|
975
1006
|
cluster: inputData.cluster,
|
|
976
1007
|
optumId: inputUpdatedData?._source?.optumId,
|
|
977
1008
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -1003,7 +1034,7 @@ export async function save( req, res ) {
|
|
|
1003
1034
|
case '==': if ( humanScore == value ) {
|
|
1004
1035
|
const record5 = {
|
|
1005
1036
|
RMEmail: inputData.RMEmail,
|
|
1006
|
-
RMName:
|
|
1037
|
+
RMName: rmName.toString(),
|
|
1007
1038
|
cluster: inputData.cluster,
|
|
1008
1039
|
optumId: inputUpdatedData?._source?.optumId,
|
|
1009
1040
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -1034,7 +1065,7 @@ export async function save( req, res ) {
|
|
|
1034
1065
|
case '===': if ( humanScore === value ) {
|
|
1035
1066
|
const record6 = {
|
|
1036
1067
|
RMEmail: inputData.RMEmail,
|
|
1037
|
-
RMName:
|
|
1068
|
+
RMName: rmName.toString(),
|
|
1038
1069
|
cluster: inputData.cluster,
|
|
1039
1070
|
optumId: inputUpdatedData?._source?.optumId,
|
|
1040
1071
|
optomEmailId: inputUpdatedData?._source?.salesmanEmailId,
|
|
@@ -2543,7 +2574,7 @@ export async function emailAlertLog( req, res ) {
|
|
|
2543
2574
|
'range': {
|
|
2544
2575
|
'createdAt': {
|
|
2545
2576
|
'gte': dayjs( inputData.fromDate ),
|
|
2546
|
-
'lte': dayjs(
|
|
2577
|
+
'lte': dayjs( inputData.toDate ),
|
|
2547
2578
|
},
|
|
2548
2579
|
},
|
|
2549
2580
|
},
|
|
@@ -2551,23 +2582,11 @@ export async function emailAlertLog( req, res ) {
|
|
|
2551
2582
|
let sort =[
|
|
2552
2583
|
{ [sortBy]: { order: inputData.sortOrder === 1 ? 'asc' : 'desc' } },
|
|
2553
2584
|
];
|
|
2554
|
-
if ( inputData.RmList && inputData.RmList?.lenght > 0 ) {
|
|
2555
|
-
filter.push( {
|
|
2556
|
-
'terms': {
|
|
2557
|
-
'RMEmail.keyword': inputData?.RmList,
|
|
2558
|
-
},
|
|
2559
|
-
} );
|
|
2560
|
-
}
|
|
2561
2585
|
|
|
2562
|
-
if ( inputData.cluster && inputData.cluster?.lenght > 0 ) {
|
|
2563
|
-
filter.push( {
|
|
2564
|
-
'terms': {
|
|
2565
|
-
'cluster.keyword': inputData?.cluster,
|
|
2566
|
-
},
|
|
2567
|
-
} );
|
|
2568
|
-
}
|
|
2569
2586
|
let search = {
|
|
2570
|
-
must: filter,
|
|
2587
|
+
'must': filter,
|
|
2588
|
+
'should': [],
|
|
2589
|
+
'minimum_should_match': 1,
|
|
2571
2590
|
};
|
|
2572
2591
|
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
2573
2592
|
search ={
|
|
@@ -2630,9 +2649,28 @@ export async function emailAlertLog( req, res ) {
|
|
|
2630
2649
|
},
|
|
2631
2650
|
},
|
|
2632
2651
|
],
|
|
2633
|
-
|
|
2652
|
+
|
|
2653
|
+
|
|
2634
2654
|
};
|
|
2635
2655
|
}
|
|
2656
|
+
|
|
2657
|
+
if ( inputData.RMList && inputData.RMList?.length > 0 ) {
|
|
2658
|
+
const shouldRMQuery =inputData.RMList.map( ( email ) => ( {
|
|
2659
|
+
wildcard: {
|
|
2660
|
+
'RMEmail.keyword': `*${email}*`,
|
|
2661
|
+
},
|
|
2662
|
+
} ) );
|
|
2663
|
+
search['should'].push( ...shouldRMQuery );
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
if ( inputData.cluster && inputData.cluster?.length > 0 ) {
|
|
2667
|
+
const shouldClusterQuery =inputData?.cluster?.map( ( cluster ) => ( {
|
|
2668
|
+
wildcard: {
|
|
2669
|
+
'RMEmail.keyword': `*${cluster}*`,
|
|
2670
|
+
},
|
|
2671
|
+
} ) );
|
|
2672
|
+
search['should'].push( ...shouldClusterQuery );
|
|
2673
|
+
}
|
|
2636
2674
|
const getQuery = {
|
|
2637
2675
|
'size': inputData.isExport == true? 50000 : inputData?.limit || 10,
|
|
2638
2676
|
'from': offset || 0,
|
|
@@ -2659,9 +2697,9 @@ export async function emailAlertLog( req, res ) {
|
|
|
2659
2697
|
optumId: item?._source?.optumId,
|
|
2660
2698
|
optomEmailId: item?._source?.optomEmailId,
|
|
2661
2699
|
storeName: item?._source?.storeName,
|
|
2662
|
-
complianceScore: Math.round( item?._source?.complianceScore || 0 ),
|
|
2663
|
-
humanScore: Math.round( item?._source?.humanScore || 0 ),
|
|
2664
|
-
trustScore: item?._source?.trustScore || '--',
|
|
2700
|
+
complianceScore: Math.round( item?._source?.complianceScore || 0 ) + ' %',
|
|
2701
|
+
humanScore: Math.round( item?._source?.humanScore || 0 )+ ' %',
|
|
2702
|
+
trustScore: item?._source?.trustScore+ ' %' || '--',
|
|
2665
2703
|
auditedId: item?._source?.auditedId,
|
|
2666
2704
|
queueId: item?._source?.queueId,
|
|
2667
2705
|
auditedBy: item?._source?.auditedBy || '--',
|
|
@@ -2682,10 +2720,9 @@ export async function emailAlertLog( req, res ) {
|
|
|
2682
2720
|
'Optom Email': element.optomEmailId || '--',
|
|
2683
2721
|
'Store Name': element.storeName,
|
|
2684
2722
|
'Audited By': element.auditedBy || '--',
|
|
2685
|
-
'Tango Score': Math.round( element.complianceScore || 0 ),
|
|
2686
|
-
|
|
2687
|
-
'
|
|
2688
|
-
'Human Audited Score': Math.round( element.humanScore || 0 ),
|
|
2723
|
+
'Tango Score': Math.round( element.complianceScore || 0 )+' %',
|
|
2724
|
+
'Trust Score': element.trustScore+' %' || '--',
|
|
2725
|
+
'Human Audited Score': Math.round( element.humanScore || 0 ) + ' %',
|
|
2689
2726
|
|
|
2690
2727
|
|
|
2691
2728
|
} );
|
|
@@ -2695,7 +2732,7 @@ export async function emailAlertLog( req, res ) {
|
|
|
2695
2732
|
} );
|
|
2696
2733
|
const mappedArrays = await Promise.all( promises );
|
|
2697
2734
|
const result = mappedArrays.flat();
|
|
2698
|
-
|
|
2735
|
+
|
|
2699
2736
|
await download( result, res );
|
|
2700
2737
|
return;
|
|
2701
2738
|
}
|
|
@@ -2704,7 +2741,6 @@ export async function emailAlertLog( req, res ) {
|
|
|
2704
2741
|
// throw error if null or undefined or empty array
|
|
2705
2742
|
|
|
2706
2743
|
|
|
2707
|
-
logger.info( { inputData: inputData, getData: response } );
|
|
2708
2744
|
return res.sendSuccess( { result: response, count: count } );
|
|
2709
2745
|
} catch ( error ) {
|
|
2710
2746
|
const err = error.message || 'Internal Server Error';
|
|
@@ -164,9 +164,9 @@ export async function sendComplianceEmail( {
|
|
|
164
164
|
|
|
165
165
|
<p class="subtitle">
|
|
166
166
|
Dear ${userName},<br><br>
|
|
167
|
-
Please ensure that all conducted eye tests meet the required compliance standards.<br>
|
|
168
|
-
Your prompt attention to this matter will help us maintain the highest standards
|
|
169
|
-
Please take a look at the below findings.
|
|
167
|
+
Please ensure that all conducted eye tests meet the required compliance standards.<br><br>
|
|
168
|
+
Your prompt attention to this matter will help us maintain the highest standards and avoid any<br>
|
|
169
|
+
discrepancies. Please take a look at the below findings.
|
|
170
170
|
</p>
|
|
171
171
|
|
|
172
172
|
<table class="table">
|