tango-app-api-audit 3.6.47 → 3.6.49

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.47",
3
+ "version": "3.6.49",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1447,7 +1447,8 @@ export async function summaryList( req, res ) {
1447
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
1448
  const fromDateIST = getISTDate( fromDate );
1449
1449
  const toDateIST = getISTDate( toDate );
1450
-
1450
+ logger.info( { fromDateIST, msg: '..............fromDateIST' } );
1451
+ logger.info( { toDateIST, msg: '..............toDateIST' } );
1451
1452
 
1452
1453
  filter= [
1453
1454
  {
@@ -2165,7 +2166,7 @@ export async function summaryList( req, res ) {
2165
2166
  if ( element?._source?.type == 'physical' ) {
2166
2167
  exportData.push( {
2167
2168
  'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
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',
2169
+ 'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )? dayjs.utc( element?._source?.updatedAt ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' ): 'NA',
2169
2170
  ...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
2170
2171
  ...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
2171
2172
  'Store Name': element?._source?.storeName,
@@ -2191,7 +2192,7 @@ export async function summaryList( req, res ) {
2191
2192
  } else {
2192
2193
  exportData.push( {
2193
2194
  'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
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',
2195
+ 'Audited Date': [ 'Re-Audited', 'Audited' ].includes( element?._source?.auditStatus )?dayjs.utc( element?._source?.updatedAt ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' ): 'NA',
2195
2196
  ...( req?.user?.role === 'superadmin' && { 'RM Name': RMName } ),
2196
2197
  ...( req?.user?.role !== 'user' && { 'Cluster Name': clusterName } ),
2197
2198
  'Store Name': element?._source?.storeName,
@@ -2326,18 +2327,19 @@ export async function summaryList( req, res ) {
2326
2327
  const minutes = Math.floor( testDuration / 60 );
2327
2328
  const seconds = testDuration % 60;
2328
2329
  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';
2330
+ temp[i].humanComplianceScore = [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus ) ?
2331
+ `${item?._source?.totalSteps > 0 ? Math.round( ( item?._source?.auditedSteps / item?._source?.totalSteps ) * 100 ) : 0} %` :
2332
+ 'NA';
2330
2333
  temp[i].min = minutes;
2331
2334
  temp[i].sec = seconds;
2332
2335
  temp[i].auditedBy = userName?.userName || '';
2333
2336
  temp[i].date = dayjs( item?._source?.date ).format( 'D MMM, YYYY' );
2334
2337
 
2335
- // auditedDate date conversion from UTC to IST (Indian Standard Time)
2338
+ // auditedDate: convert from UTC to Asia/Kolkata time zone
2336
2339
  if ( [ 'Re-Audited', 'Audited' ].includes( item?._source?.auditStatus ) ) {
2337
2340
  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
+ const auditedDateKolkata = dayjs.utc( auditedDate ).tz( 'Asia/Kolkata' ).format( 'D MMM, YYYY' );
2342
+ temp[i].auditedDate = auditedDateKolkata;
2341
2343
  } else {
2342
2344
  temp[i].auditedDate = 'NA';
2343
2345
  }
@@ -2627,7 +2629,7 @@ export async function summaryCard( req, res ) {
2627
2629
  // 5. Past week comparison
2628
2630
  'trend': {
2629
2631
  date_range: {
2630
- field: 'date',
2632
+ field: inputData?.dateType === 'auditedDate' ?'updatedAt':'date',
2631
2633
  format: 'yyyy-MM-dd',
2632
2634
  ranges: [
2633
2635
  { key: 'previous', from: 'now-14d/d', to: 'now-7d/d' },