tango-app-api-audit 3.6.9 → 3.6.11
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
|
@@ -1207,7 +1207,7 @@ export async function summaryList( req, res ) {
|
|
|
1207
1207
|
const limit = inputData.limit || 10;
|
|
1208
1208
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1209
1209
|
|
|
1210
|
-
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date', 'ComplianceScore' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1210
|
+
const sortBy = inputData?.sortBy ? [ 'coveredStepsAI', 'trustScore', 'date', 'ComplianceScore', 'auditedSteps' ].includes( inputData.sortBy ) ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
|
|
1211
1211
|
const order = inputData?.sortOrder || -1;
|
|
1212
1212
|
|
|
1213
1213
|
let filter= [
|
|
@@ -1221,7 +1221,15 @@ export async function summaryList( req, res ) {
|
|
|
1221
1221
|
},
|
|
1222
1222
|
|
|
1223
1223
|
];
|
|
1224
|
-
|
|
1224
|
+
|
|
1225
|
+
if ( inputData?.auditStatus && inputData?.auditStatus?.length > 0 ) {
|
|
1226
|
+
filter.push( {
|
|
1227
|
+
'terms': {
|
|
1228
|
+
'auditStatus.keyword': inputData.auditStatus,
|
|
1229
|
+
},
|
|
1230
|
+
} );
|
|
1231
|
+
}
|
|
1232
|
+
if ( inputData?.demographics && inputData?.demographics?.length > 0 ) {
|
|
1225
1233
|
filter.push( {
|
|
1226
1234
|
'terms': {
|
|
1227
1235
|
'visitorsType.keyword': inputData.demographics,
|
|
@@ -1236,13 +1244,13 @@ export async function summaryList( req, res ) {
|
|
|
1236
1244
|
|
|
1237
1245
|
} );
|
|
1238
1246
|
}
|
|
1239
|
-
if ( inputData.complianceScore && inputData.complianceScore
|
|
1240
|
-
|
|
1247
|
+
if ( inputData.complianceScore && inputData.complianceScore?.length > null ) {
|
|
1248
|
+
const values = Array.isArray( inputData.complianceScore ) ?
|
|
1249
|
+
inputData.complianceScore.map( Number ) :
|
|
1250
|
+
[ Number( inputData.complianceScore ) ];
|
|
1241
1251
|
filter.push( {
|
|
1242
|
-
|
|
1243
|
-
'ComplianceScore':
|
|
1244
|
-
lt: inputData.complianceScore,
|
|
1245
|
-
},
|
|
1252
|
+
'terms': {
|
|
1253
|
+
'ComplianceScore': values,
|
|
1246
1254
|
},
|
|
1247
1255
|
|
|
1248
1256
|
} );
|
|
@@ -1848,6 +1856,7 @@ export async function summaryList( req, res ) {
|
|
|
1848
1856
|
if ( element?._source?.type == 'physical' ) {
|
|
1849
1857
|
exportData.push( {
|
|
1850
1858
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1859
|
+
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs( element?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA',
|
|
1851
1860
|
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
1852
1861
|
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
1853
1862
|
'Store Name': element?._source?.storeName,
|
|
@@ -1857,6 +1866,7 @@ export async function summaryList( req, res ) {
|
|
|
1857
1866
|
'Queue ID': element?._source?.queueId,
|
|
1858
1867
|
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1859
1868
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1869
|
+
'Steps Covered By User': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?element?._source?.auditedSteps :'NA',
|
|
1860
1870
|
'Trust Score': element?._source?.trustScore == null || element?._source?.trustScore ==undefined ? 'NA' : `${element?._source?.trustScore} %`,
|
|
1861
1871
|
'Visitor Type': element?._source?.visitorsType,
|
|
1862
1872
|
'Test Duration': duration || '',
|
|
@@ -1869,6 +1879,7 @@ export async function summaryList( req, res ) {
|
|
|
1869
1879
|
} else {
|
|
1870
1880
|
exportData.push( {
|
|
1871
1881
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
1882
|
+
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs( element?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA',
|
|
1872
1883
|
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
1873
1884
|
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
1874
1885
|
'Store Name': element?._source?.storeName,
|
|
@@ -1878,6 +1889,7 @@ export async function summaryList( req, res ) {
|
|
|
1878
1889
|
'Engagement ID': element?._source?.engagementId,
|
|
1879
1890
|
'Tango Score': `${element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0} %`,
|
|
1880
1891
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1892
|
+
'Steps Covered By User': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?element?._source?.auditedSteps :'NA',
|
|
1881
1893
|
'Trust Score': element?._source?.trustScore == null || element?._source?.trustScore ==undefined ? 'NA' : `${element?._source?.trustScore} %`,
|
|
1882
1894
|
'Test Duration': duration || '',
|
|
1883
1895
|
'Audit Status': element?._source?.auditStatus || '',
|
|
@@ -2019,6 +2031,7 @@ export async function summaryList( req, res ) {
|
|
|
2019
2031
|
temp[i].sec = seconds;
|
|
2020
2032
|
temp[i].auditedBy = userName?.userName || '';
|
|
2021
2033
|
temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
|
|
2034
|
+
temp[i].auditedDate = [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus )?dayjs( item?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA';
|
|
2022
2035
|
temp[i].RMName = RMName;
|
|
2023
2036
|
temp[i].clusterName =clusterName;
|
|
2024
2037
|
temp[i].RMEmail =RMEmail;
|
|
@@ -2070,13 +2083,11 @@ export async function summaryCard( req, res ) {
|
|
|
2070
2083
|
} );
|
|
2071
2084
|
}
|
|
2072
2085
|
|
|
2073
|
-
if ( inputData?.complianceScore && inputData?.complianceScore
|
|
2086
|
+
if ( inputData?.complianceScore && inputData?.complianceScore?.length > 0 ) {
|
|
2074
2087
|
filter.push(
|
|
2075
2088
|
{
|
|
2076
|
-
|
|
2077
|
-
ComplianceScore:
|
|
2078
|
-
lt: inputData?.complianceScore, // 🔹 adjust threshold here (e.g. gte: 50 for >= 50%)
|
|
2079
|
-
},
|
|
2089
|
+
'terms': {
|
|
2090
|
+
'ComplianceScore': inputData.complianceScore,
|
|
2080
2091
|
},
|
|
2081
2092
|
},
|
|
2082
2093
|
);
|
|
@@ -150,12 +150,12 @@ export const summaryListSchema = joi.object( {
|
|
|
150
150
|
demographics: joi.array().optional(),
|
|
151
151
|
RMList: joi.array().items(
|
|
152
152
|
joi.string().required(),
|
|
153
|
-
).
|
|
153
|
+
).required(),
|
|
154
154
|
cluster: joi.array().items(
|
|
155
155
|
joi.string().optional(),
|
|
156
156
|
).optional(),
|
|
157
157
|
storeId: joi.array().items( joi.string().required() ).required(),
|
|
158
|
-
complianceScore: joi.
|
|
158
|
+
complianceScore: joi.array().items( joi.number().required() ).optional(),
|
|
159
159
|
nearAddition: joi.string().optional().allow( '' ),
|
|
160
160
|
isExport: joi.boolean().optional(),
|
|
161
161
|
searchValue: joi.string().optional().allow( '' ),
|
|
@@ -164,6 +164,7 @@ export const summaryListSchema = joi.object( {
|
|
|
164
164
|
category: joi.string().optional() .valid( 'fake', 'genuine' ),
|
|
165
165
|
offset: joi.number().optional(),
|
|
166
166
|
limit: joi.number().optional(),
|
|
167
|
+
auditStatus: joi.array().items( joi.string().required().valid( 'Re-Audited', 'Audited', 'In-Progress', 'Yet-to-Audit' ) ).optional(),
|
|
167
168
|
} );
|
|
168
169
|
|
|
169
170
|
export const summaryListValid = {
|
|
@@ -225,7 +226,7 @@ export const summaryCardSchema = joi.object( {
|
|
|
225
226
|
joi.string().optional(),
|
|
226
227
|
).optional(),
|
|
227
228
|
storeId: joi.array().items( joi.string().required() ).required(),
|
|
228
|
-
complianceScore: joi.
|
|
229
|
+
complianceScore: joi.array().items( joi.number().required() ).optional(),
|
|
229
230
|
nearAddition: joi.string().optional().allow( '' ),
|
|
230
231
|
category: joi.string().optional() .valid( 'fake', 'genuine' ),
|
|
231
232
|
} );
|
|
@@ -22,7 +22,7 @@ eyeTestAuditRouter.post( '/summary-card', isAllowedSessionHandler, accessVerific
|
|
|
22
22
|
eyeTestAuditRouter.post( '/email-alert-log', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( emailAlertLogValid ), emailAlertLog );
|
|
23
23
|
|
|
24
24
|
eyeTestAuditRouter.post( '/cluster-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( clusterListValid ), clusterList );
|
|
25
|
-
eyeTestAuditRouter.get( '/rm-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ),
|
|
25
|
+
eyeTestAuditRouter.get( '/rm-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( rmListValid ), rmList );
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
// setting
|
|
@@ -2,20 +2,20 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
2
2
|
|
|
3
3
|
export async function roleValidation( req, res, next ) {
|
|
4
4
|
try {
|
|
5
|
-
const userRole = req?.user?.role;
|
|
5
|
+
// const userRole = req?.user?.role;
|
|
6
6
|
req.body.clientId = req?.user?.userType == 'tango'? req?.body?.clientId : req?.user?.clientId;
|
|
7
|
-
switch ( userRole ) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
7
|
+
// switch ( userRole ) {
|
|
8
|
+
// case 'user':
|
|
9
|
+
// req.body.RMList = [ req?.user?.email ];
|
|
10
|
+
// break;
|
|
11
|
+
// case 'admin':
|
|
12
|
+
// req.body.RMList = [ req?.user?.email ];
|
|
13
|
+
// // delete req?.body?.RMList;
|
|
14
|
+
// break;
|
|
15
|
+
// case 'superadmin':
|
|
16
|
+
// break;
|
|
17
|
+
// default: return res.sendError( 'forbidden to access: you must be User or Admin or Super Admin', 403 );
|
|
18
|
+
// }
|
|
19
19
|
next();
|
|
20
20
|
return;
|
|
21
21
|
} catch ( error ) {
|