tango-app-api-audit 3.6.46 → 3.6.48

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.6.46",
3
+ "version": "3.6.48",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2165,7 +2165,7 @@ export async function summaryList( req, res ) {
2165
2165
  if ( element?._source?.type == 'physical' ) {
2166
2166
  exportData.push( {
2167
2167
  'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
2168
- '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 ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' ): 'NA',
2169
2169
  ...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
2170
2170
  ...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
2171
2171
  'Store Name': element?._source?.storeName,
@@ -2191,7 +2191,7 @@ export async function summaryList( req, res ) {
2191
2191
  } else {
2192
2192
  exportData.push( {
2193
2193
  'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
2194
- '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 ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' ): 'NA',
2195
2195
  ...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
2196
2196
  ...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
2197
2197
  'Store Name': element?._source?.storeName,
@@ -2232,39 +2232,6 @@ export async function summaryList( req, res ) {
2232
2232
  let RMEmail = '';
2233
2233
  let clusterName='';
2234
2234
  if ( item?._source?.storeId&&item?._source?.storeId!='' ) {
2235
- // const rmListQuery =[
2236
- // {
2237
- // $match: {
2238
- // $and: [
2239
- // {
2240
- // clientId: { $eq: inputData?.clientId },
2241
- // },
2242
- // {
2243
- // configureType: { $eq: 'user' },
2244
- // },
2245
- // ],
2246
- // },
2247
- // },
2248
- // {
2249
- // $unwind: {
2250
- // path: '$userList', preserveNullAndEmptyArrays: true,
2251
- // },
2252
- // },
2253
- // {
2254
- // $group: {
2255
- // _id: null,
2256
- // list: { $addToSet: '$userList.email' },
2257
- // },
2258
- // },
2259
- // {
2260
- // $project: {
2261
- // _id: 0,
2262
- // list: 1,
2263
- // },
2264
- // },
2265
- // ];
2266
- // const getRMList = await aggregateEyeTestConfig( rmListQuery );
2267
-
2268
2235
  const getRMList = [
2269
2236
  {
2270
2237
  list: [ 'marellapudi.ajay@lenskart.com',
@@ -2358,18 +2325,29 @@ export async function summaryList( req, res ) {
2358
2325
  const testDuration = item?._source?.testDuration;
2359
2326
  const minutes = Math.floor( testDuration / 60 );
2360
2327
  const seconds = testDuration % 60;
2361
- temp[i].complianceScore = `${item?._source?.totalSteps>0 ? Math.round( ( item?._source?.coveredStepsAI/ item?._source?.totalSteps )*100 ): 0} %`;
2362
- 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';
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 ) ?
2330
+ `${item?._source?.totalSteps > 0 ? Math.round( ( item?._source?.auditedSteps / item?._source?.totalSteps ) * 100 ) : 0} %` :
2331
+ 'NA';
2363
2332
  temp[i].min = minutes;
2364
2333
  temp[i].sec = seconds;
2365
2334
  temp[i].auditedBy = userName?.userName || '';
2366
2335
  temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
2367
- temp[i].auditedDate = [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus )?dayjs( item?._source?.updatedAt ).format( 'D MMM, YYYY' ): 'NA';
2336
+
2337
+ // auditedDate: convert from UTC to Asia/Kolkata time zone
2338
+ if ( [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus ) ) {
2339
+ const auditedDate = item?._source?.updatedAt;
2340
+ const auditedDateKolkata = dayjs.utc( auditedDate ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' );
2341
+ temp[i].auditedDate = auditedDateKolkata;
2342
+ } else {
2343
+ temp[i].auditedDate = 'NA';
2344
+ }
2345
+
2368
2346
  temp[i].RMName = RMName;
2369
- temp[i].clusterName =clusterName;
2370
- temp[i].RMEmail =RMEmail;
2347
+ temp[i].clusterName = clusterName;
2348
+ temp[i].RMEmail = RMEmail;
2371
2349
  const trustScore = temp[i].trustScore;
2372
- temp[i].trustScore = ( trustScore == null || trustScore == undefined ) ? 'NA' :`${trustScore + ' %'}`;
2350
+ temp[i].trustScore = ( trustScore == null || trustScore == undefined ) ? 'NA' : `${trustScore + ' %'}`;
2373
2351
  temp[i]._id = item?._id;
2374
2352
  }
2375
2353
  }
@@ -2650,7 +2628,7 @@ export async function summaryCard( req, res ) {
2650
2628
  // 5. Past week comparison
2651
2629
  'trend': {
2652
2630
  date_range: {
2653
- field: 'date',
2631
+ field: inputData?.dateType === 'auditedDate' ?'updatedAt':'date',
2654
2632
  format: 'yyyy-MM-dd',
2655
2633
  ranges: [
2656
2634
  { key: 'previous', from: 'now-14d/d', to: 'now-7d/d' },