tango-app-api-audit 3.6.44 → 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
|
@@ -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;
|
|
@@ -2355,15 +2387,9 @@ export async function summaryCard( req, res ) {
|
|
|
2355
2387
|
const inputData = req.body;
|
|
2356
2388
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
2357
2389
|
|
|
2390
|
+
|
|
2358
2391
|
let filter =[
|
|
2359
|
-
|
|
2360
|
-
'range': {
|
|
2361
|
-
'date': {
|
|
2362
|
-
'gte': new Date( inputData.fromDate ),
|
|
2363
|
-
'lte': new Date( inputData.toDate ),
|
|
2364
|
-
},
|
|
2365
|
-
},
|
|
2366
|
-
},
|
|
2392
|
+
|
|
2367
2393
|
{
|
|
2368
2394
|
term: {
|
|
2369
2395
|
'type.keyword': inputData?.type,
|
|
@@ -2375,6 +2401,50 @@ export async function summaryCard( req, res ) {
|
|
|
2375
2401
|
},
|
|
2376
2402
|
},
|
|
2377
2403
|
];
|
|
2404
|
+
|
|
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
|
+
|
|
2423
|
+
filter.push(
|
|
2424
|
+
{
|
|
2425
|
+
'range': {
|
|
2426
|
+
'updatedAt': {
|
|
2427
|
+
'gte': new Date( fromDateIST ),
|
|
2428
|
+
'lte': new Date( toDateIST ),
|
|
2429
|
+
},
|
|
2430
|
+
},
|
|
2431
|
+
},
|
|
2432
|
+
|
|
2433
|
+
);
|
|
2434
|
+
} else {
|
|
2435
|
+
filter.push(
|
|
2436
|
+
{
|
|
2437
|
+
'range': {
|
|
2438
|
+
'date': {
|
|
2439
|
+
'gte': new Date( inputData.fromDate ),
|
|
2440
|
+
'lte': new Date( inputData.toDate ),
|
|
2441
|
+
},
|
|
2442
|
+
},
|
|
2443
|
+
},
|
|
2444
|
+
|
|
2445
|
+
);
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2378
2448
|
if ( inputData?.demographics && inputData?.demographics?.length > 0 ) {
|
|
2379
2449
|
filter.push( {
|
|
2380
2450
|
terms: {
|
|
@@ -2615,6 +2685,7 @@ export async function summaryCard( req, res ) {
|
|
|
2615
2685
|
|
|
2616
2686
|
|
|
2617
2687
|
const getOutput = await getOpenSearchData( openSearch?.EyeTestInput, getQuery );
|
|
2688
|
+
|
|
2618
2689
|
const initialValue = {
|
|
2619
2690
|
totalFiles: 0,
|
|
2620
2691
|
completedFiles: 0,
|
|
@@ -176,7 +176,7 @@ export const summaryListValid = {
|
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
export const summaryCardSchema = joi.object( {
|
|
179
|
-
|
|
179
|
+
dateType: joi.string().optional().valid( 'fileDate', 'auditedDate' ),
|
|
180
180
|
fromDate: joi.string()
|
|
181
181
|
.pattern( /^\d{4}-\d{2}-\d{2}$/, 'YYYY-MM-DD format' )
|
|
182
182
|
.required()
|