tango-app-api-audit 3.6.6 → 3.6.8
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,
|
|
@@ -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;
|
|
@@ -150,7 +150,7 @@ 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(),
|
|
@@ -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 = {
|
|
@@ -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 ) {
|