tango-app-api-audit 3.6.45 → 3.6.46

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.45",
3
+ "version": "3.6.46",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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( inputData.fromDate ),
1426
- 'lte': new Date( inputData.toDate ),
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;
@@ -2371,12 +2403,29 @@ export async function summaryCard( req, res ) {
2371
2403
  ];
2372
2404
 
2373
2405
  if ( inputData?.dateType === 'auditedDate' ) {
2406
+ let fromDate = new Date( inputData?.fromDate );
2407
+ let toDate = new Date( inputData?.toDate );
2408
+
2409
+
2410
+ // Set to 23:59:59.999 for EOD
2411
+ toDate.setHours( 23, 59, 59, 999 );
2412
+
2413
+
2414
+ // Set to 23:59:59.999 for EOD
2415
+ fromDate.setHours( 0, 0, 0, 0 );
2416
+
2417
+
2418
+ // If toDate is set to midnight (i.e., no time) OR is an ISO string at 00:00:00, set to end of day
2419
+ const fromDateIST = getISTDate( fromDate );
2420
+ const toDateIST = getISTDate( toDate );
2421
+
2422
+
2374
2423
  filter.push(
2375
2424
  {
2376
2425
  'range': {
2377
2426
  'updatedAt': {
2378
- 'gte': new Date( inputData.fromDate ),
2379
- 'lte': new Date( inputData.toDate ),
2427
+ 'gte': new Date( fromDateIST ),
2428
+ 'lte': new Date( toDateIST ),
2380
2429
  },
2381
2430
  },
2382
2431
  },
@@ -2636,6 +2685,7 @@ export async function summaryCard( req, res ) {
2636
2685
 
2637
2686
 
2638
2687
  const getOutput = await getOpenSearchData( openSearch?.EyeTestInput, getQuery );
2688
+
2639
2689
  const initialValue = {
2640
2690
  totalFiles: 0,
2641
2691
  completedFiles: 0,