tango-app-api-audit 3.6.45 → 3.6.47
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
|
@@ -1395,6 +1395,16 @@ export async function userAuditedData( req, res ) {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
}
|
|
1397
1397
|
|
|
1398
|
+
function getISTDate( dateString ) {
|
|
1399
|
+
// If input is already a Date object, clone it
|
|
1400
|
+
let dateObj = typeof dateString === 'string' ? new Date( dateString ) : new Date( dateString.getTime() );
|
|
1401
|
+
// Get UTC time in milliseconds
|
|
1402
|
+
const utc = dateObj.getTime() + ( dateObj.getTimezoneOffset() * 60000 );
|
|
1403
|
+
// IST offset is +5:30, which is 19800000 ms
|
|
1404
|
+
return new Date( utc + ( 5.5 * 60 * 60 * 1000 ) );
|
|
1405
|
+
// set at first to eod
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1398
1408
|
export async function summaryList( req, res ) {
|
|
1399
1409
|
try {
|
|
1400
1410
|
// declare inputData and get request body
|
|
@@ -1418,12 +1428,33 @@ export async function summaryList( req, res ) {
|
|
|
1418
1428
|
// declare filter and assign range values from inputData
|
|
1419
1429
|
let filter;
|
|
1420
1430
|
if ( inputData?.dateType === 'auditedDate' ) {
|
|
1431
|
+
// Ensure toDate includes end of day in the filter (23:59:59.999)
|
|
1432
|
+
|
|
1433
|
+
// Helper to create IST Date object from input date string
|
|
1434
|
+
|
|
1435
|
+
let fromDate = new Date( inputData?.fromDate );
|
|
1436
|
+
let toDate = new Date( inputData?.toDate );
|
|
1437
|
+
|
|
1438
|
+
|
|
1439
|
+
// Set to 23:59:59.999 for EOD
|
|
1440
|
+
toDate.setHours( 23, 59, 59, 999 );
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
// Set to 23:59:59.999 for EOD
|
|
1444
|
+
fromDate.setHours( 0, 0, 0, 0 );
|
|
1445
|
+
|
|
1446
|
+
|
|
1447
|
+
// If toDate is set to midnight (i.e., no time) OR is an ISO string at 00:00:00, set to end of day
|
|
1448
|
+
const fromDateIST = getISTDate( fromDate );
|
|
1449
|
+
const toDateIST = getISTDate( toDate );
|
|
1450
|
+
|
|
1451
|
+
|
|
1421
1452
|
filter= [
|
|
1422
1453
|
{
|
|
1423
1454
|
'range': {
|
|
1424
1455
|
'updatedAt': {
|
|
1425
|
-
'gte': new Date(
|
|
1426
|
-
'lte': new Date(
|
|
1456
|
+
'gte': new Date( fromDateIST ),
|
|
1457
|
+
'lte': new Date( toDateIST ),
|
|
1427
1458
|
},
|
|
1428
1459
|
},
|
|
1429
1460
|
},
|
|
@@ -1997,6 +2028,7 @@ export async function summaryList( req, res ) {
|
|
|
1997
2028
|
};
|
|
1998
2029
|
|
|
1999
2030
|
const result = await getOpenSearchData( openSearch.EyeTestInput, searchQuery );
|
|
2031
|
+
logger.info( { result, message: '.......result' } );
|
|
2000
2032
|
const getCount = inputData.isExport==true? null:await getOpenSearchCount( openSearch.EyeTestInput, countQuery );
|
|
2001
2033
|
const count =inputData.isExport==true?null: getCount?.body?.count;
|
|
2002
2034
|
const searchValue = result?.body?.hits?.hits;
|
|
@@ -2133,7 +2165,7 @@ export async function summaryList( req, res ) {
|
|
|
2133
2165
|
if ( element?._source?.type == 'physical' ) {
|
|
2134
2166
|
exportData.push( {
|
|
2135
2167
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
2136
|
-
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs( element?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA',
|
|
2168
|
+
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs.utc( element?._source?.updatedAt ).add( 5, 'hour' ).add( 30, 'minute' ).format( 'D MMM, YYYY' ): 'NA',
|
|
2137
2169
|
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
2138
2170
|
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
2139
2171
|
'Store Name': element?._source?.storeName,
|
|
@@ -2159,7 +2191,7 @@ export async function summaryList( req, res ) {
|
|
|
2159
2191
|
} else {
|
|
2160
2192
|
exportData.push( {
|
|
2161
2193
|
'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
|
|
2162
|
-
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs( element?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA',
|
|
2194
|
+
'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs.utc( element?._source?.updatedAt ).add( 5, 'hour' ).add( 30, 'minute' ).format( 'D MMM, YYYY' ): 'NA',
|
|
2163
2195
|
...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
|
|
2164
2196
|
...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
|
|
2165
2197
|
'Store Name': element?._source?.storeName,
|
|
@@ -2200,39 +2232,6 @@ export async function summaryList( req, res ) {
|
|
|
2200
2232
|
let RMEmail = '';
|
|
2201
2233
|
let clusterName='';
|
|
2202
2234
|
if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
|
|
2203
|
-
// const rmListQuery =[
|
|
2204
|
-
// {
|
|
2205
|
-
// $match: {
|
|
2206
|
-
// $and: [
|
|
2207
|
-
// {
|
|
2208
|
-
// clientId: { $eq: inputData?.clientId },
|
|
2209
|
-
// },
|
|
2210
|
-
// {
|
|
2211
|
-
// configureType: { $eq: 'user' },
|
|
2212
|
-
// },
|
|
2213
|
-
// ],
|
|
2214
|
-
// },
|
|
2215
|
-
// },
|
|
2216
|
-
// {
|
|
2217
|
-
// $unwind: {
|
|
2218
|
-
// path: '$userList', preserveNullAndEmptyArrays: true,
|
|
2219
|
-
// },
|
|
2220
|
-
// },
|
|
2221
|
-
// {
|
|
2222
|
-
// $group: {
|
|
2223
|
-
// _id: null,
|
|
2224
|
-
// list: { $addToSet: '$userList.email' },
|
|
2225
|
-
// },
|
|
2226
|
-
// },
|
|
2227
|
-
// {
|
|
2228
|
-
// $project: {
|
|
2229
|
-
// _id: 0,
|
|
2230
|
-
// list: 1,
|
|
2231
|
-
// },
|
|
2232
|
-
// },
|
|
2233
|
-
// ];
|
|
2234
|
-
// const getRMList = await aggregateEyeTestConfig( rmListQuery );
|
|
2235
|
-
|
|
2236
2235
|
const getRMList = [
|
|
2237
2236
|
{
|
|
2238
2237
|
list: [ 'marellapudi.ajay@lenskart.com',
|
|
@@ -2326,18 +2325,28 @@ export async function summaryList( req, res ) {
|
|
|
2326
2325
|
const testDuration = item?._source?.testDuration;
|
|
2327
2326
|
const minutes = Math.floor( testDuration / 60 );
|
|
2328
2327
|
const seconds = testDuration % 60;
|
|
2329
|
-
temp[i].complianceScore = `${item?._source?.totalSteps>0 ? Math.round( ( item?._source?.coveredStepsAI/ item?._source?.totalSteps )*100 ): 0} %`;
|
|
2330
|
-
temp[i].humanComplianceScore = [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus )
|
|
2328
|
+
temp[i].complianceScore = `${item?._source?.totalSteps > 0 ? Math.round( ( item?._source?.coveredStepsAI / item?._source?.totalSteps ) * 100 ) : 0} %`;
|
|
2329
|
+
temp[i].humanComplianceScore = [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus ) ? `${item?._source?.totalSteps > 0 ? Math.round( ( item?._source?.auditedSteps / item?._source?.totalSteps ) * 100 ) : 0} %` : 'NA';
|
|
2331
2330
|
temp[i].min = minutes;
|
|
2332
2331
|
temp[i].sec = seconds;
|
|
2333
2332
|
temp[i].auditedBy = userName?.userName || '';
|
|
2334
2333
|
temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
|
|
2335
|
-
|
|
2334
|
+
|
|
2335
|
+
// auditedDate date conversion from UTC to IST (Indian Standard Time)
|
|
2336
|
+
if ( [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus ) ) {
|
|
2337
|
+
const auditedDate = item?._source?.updatedAt;
|
|
2338
|
+
// Convert auditedDate from UTC to IST
|
|
2339
|
+
const auditedDateIST = dayjs.utc( auditedDate ).add( 5, 'hour' ).add( 30, 'minute' ).format( 'D MMM, YYYY' );
|
|
2340
|
+
temp[i].auditedDate = auditedDateIST;
|
|
2341
|
+
} else {
|
|
2342
|
+
temp[i].auditedDate = 'NA';
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2336
2345
|
temp[i].RMName = RMName;
|
|
2337
|
-
temp[i].clusterName =clusterName;
|
|
2338
|
-
temp[i].RMEmail =RMEmail;
|
|
2346
|
+
temp[i].clusterName = clusterName;
|
|
2347
|
+
temp[i].RMEmail = RMEmail;
|
|
2339
2348
|
const trustScore = temp[i].trustScore;
|
|
2340
|
-
temp[i].trustScore = ( trustScore == null || trustScore == undefined ) ? 'NA'
|
|
2349
|
+
temp[i].trustScore = ( trustScore == null || trustScore == undefined ) ? 'NA' : `${trustScore + ' %'}`;
|
|
2341
2350
|
temp[i]._id = item?._id;
|
|
2342
2351
|
}
|
|
2343
2352
|
}
|
|
@@ -2371,12 +2380,29 @@ export async function summaryCard( req, res ) {
|
|
|
2371
2380
|
];
|
|
2372
2381
|
|
|
2373
2382
|
if ( inputData?.dateType === 'auditedDate' ) {
|
|
2383
|
+
let fromDate = new Date( inputData?.fromDate );
|
|
2384
|
+
let toDate = new Date( inputData?.toDate );
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
// Set to 23:59:59.999 for EOD
|
|
2388
|
+
toDate.setHours( 23, 59, 59, 999 );
|
|
2389
|
+
|
|
2390
|
+
|
|
2391
|
+
// Set to 23:59:59.999 for EOD
|
|
2392
|
+
fromDate.setHours( 0, 0, 0, 0 );
|
|
2393
|
+
|
|
2394
|
+
|
|
2395
|
+
// If toDate is set to midnight (i.e., no time) OR is an ISO string at 00:00:00, set to end of day
|
|
2396
|
+
const fromDateIST = getISTDate( fromDate );
|
|
2397
|
+
const toDateIST = getISTDate( toDate );
|
|
2398
|
+
|
|
2399
|
+
|
|
2374
2400
|
filter.push(
|
|
2375
2401
|
{
|
|
2376
2402
|
'range': {
|
|
2377
2403
|
'updatedAt': {
|
|
2378
|
-
'gte': new Date(
|
|
2379
|
-
'lte': new Date(
|
|
2404
|
+
'gte': new Date( fromDateIST ),
|
|
2405
|
+
'lte': new Date( toDateIST ),
|
|
2380
2406
|
},
|
|
2381
2407
|
},
|
|
2382
2408
|
},
|
|
@@ -2636,6 +2662,7 @@ export async function summaryCard( req, res ) {
|
|
|
2636
2662
|
|
|
2637
2663
|
|
|
2638
2664
|
const getOutput = await getOpenSearchData( openSearch?.EyeTestInput, getQuery );
|
|
2665
|
+
|
|
2639
2666
|
const initialValue = {
|
|
2640
2667
|
totalFiles: 0,
|
|
2641
2668
|
completedFiles: 0,
|