tango-app-api-audit 3.4.8 → 3.4.10
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
|
@@ -2345,12 +2345,21 @@ export async function userMetrics( req, res ) {
|
|
|
2345
2345
|
beforeCount: 1,
|
|
2346
2346
|
afterCount: 1,
|
|
2347
2347
|
mappingPerc: {
|
|
2348
|
-
$
|
|
2348
|
+
$cond: [
|
|
2349
|
+
{ $and: [
|
|
2350
|
+
{ $gt: [ '$beforeCount', 0 ] },
|
|
2351
|
+
{ $gt: [ '$afterCount', 0 ] },
|
|
2352
|
+
] },
|
|
2349
2353
|
{
|
|
2350
|
-
$
|
|
2351
|
-
{
|
|
2354
|
+
$round: [
|
|
2355
|
+
{
|
|
2356
|
+
$multiply: [
|
|
2357
|
+
{ $divide: [ '$afterCount', '$beforeCount' ] }, 100,
|
|
2358
|
+
],
|
|
2359
|
+
}, 2,
|
|
2352
2360
|
],
|
|
2353
|
-
},
|
|
2361
|
+
},
|
|
2362
|
+
0,
|
|
2354
2363
|
],
|
|
2355
2364
|
},
|
|
2356
2365
|
checkIntime: 1,
|
|
@@ -2535,7 +2544,7 @@ export async function userMetrics( req, res ) {
|
|
|
2535
2544
|
'Check Intime': '$checkIntime',
|
|
2536
2545
|
'Check OutTime': '$checkOutTime',
|
|
2537
2546
|
'Working Hours': '$workingHours',
|
|
2538
|
-
'Audited Date': { $dateToString: { format: '%Y
|
|
2547
|
+
'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
2539
2548
|
},
|
|
2540
2549
|
},
|
|
2541
2550
|
);
|
|
@@ -4733,6 +4742,7 @@ export async function auditViewLogs( req, res ) {
|
|
|
4733
4742
|
return res.sendError( 'Please give valid modueType', 400 );
|
|
4734
4743
|
}
|
|
4735
4744
|
}
|
|
4745
|
+
logger.info( { query: logsQuery, message: 'unattended' } );
|
|
4736
4746
|
const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
|
|
4737
4747
|
logger.info( { logs: logs.body.hits, inputData: inputData, auditLog: parsedOpenSearch.auditLog } );
|
|
4738
4748
|
if ( logs.body.hits.hits.length > 0 ) {
|
|
@@ -4763,36 +4773,32 @@ export async function auditViewLogs( req, res ) {
|
|
|
4763
4773
|
}
|
|
4764
4774
|
}
|
|
4765
4775
|
|
|
4766
|
-
export async function convertTimestampToDateTime( timestamp ) {
|
|
4767
|
-
// Check if the timestamp is too large (nanoseconds), then convert it to milliseconds
|
|
4768
|
-
if ( timestamp > 9999999999999 ) {
|
|
4769
|
-
timestamp = Math.floor( timestamp / 1000 ); // Convert to milliseconds if needed
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
|
-
// Add 5 hours and 30 minutes in milliseconds
|
|
4773
|
-
const timeOffset = ( 5 * 60 * 60 * 1000 ) + ( 30 * 60 * 1000 );
|
|
4774
4776
|
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
if (
|
|
4783
|
-
|
|
4777
|
+
export async function convertTimestampToDateTime( timestamp ) {
|
|
4778
|
+
let date;
|
|
4779
|
+
if ( typeof timestamp === 'string' ) {
|
|
4780
|
+
date = new Date( timestamp );
|
|
4781
|
+
if ( isNaN( date.getTime() ) ) {
|
|
4782
|
+
throw new Error( 'Invalid ISO string timestamp provided' );
|
|
4783
|
+
}
|
|
4784
|
+
} else if ( typeof timestamp === 'number' ) { // Handle Unix timestamp input (e.g., 1727785440597)
|
|
4785
|
+
if ( timestamp.toString().length <= 10 ) {
|
|
4786
|
+
timestamp *= 1000; // Convert seconds to milliseconds
|
|
4787
|
+
}
|
|
4788
|
+
date = new Date( timestamp );
|
|
4789
|
+
} else { // Handle invalid input type
|
|
4790
|
+
throw new Error( 'Invalid input: Timestamp must be a valid ISO string or number' );
|
|
4784
4791
|
}
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
const
|
|
4788
|
-
const
|
|
4789
|
-
const
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
const
|
|
4793
|
-
const
|
|
4794
|
-
|
|
4795
|
-
// Return formatted date and time string
|
|
4792
|
+
const timeOffset = ( 5 * 60 * 60 * 1000 ) + ( 30 * 60 * 1000 ); // 5 hours and 30 minutes in milliseconds
|
|
4793
|
+
const adjustedTimestamp = date.getTime() + timeOffset;
|
|
4794
|
+
const adjustedDate = new Date( adjustedTimestamp );
|
|
4795
|
+
const year = adjustedDate.getFullYear();
|
|
4796
|
+
const month = ( '0' + ( adjustedDate.getMonth() + 1 ) ).slice( -2 ); // Months are zero-based
|
|
4797
|
+
const day = ( '0' + adjustedDate.getDate() ).slice( -2 );
|
|
4798
|
+
|
|
4799
|
+
const hours = ( '0' + adjustedDate.getHours() ).slice( -2 );
|
|
4800
|
+
const minutes = ( '0' + adjustedDate.getMinutes() ).slice( -2 );
|
|
4801
|
+
const seconds = ( '0' + adjustedDate.getSeconds() ).slice( -2 );
|
|
4796
4802
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
4797
4803
|
}
|
|
4798
4804
|
|
|
@@ -3077,7 +3077,7 @@ export async function userMetrics( req, res ) {
|
|
|
3077
3077
|
'Check Intime': '$checkIntime',
|
|
3078
3078
|
'Check OutTime': '$checkOutTime',
|
|
3079
3079
|
'Working Hours': '$workingHours',
|
|
3080
|
-
'Audited Date': { $dateToString: { format: '%Y
|
|
3080
|
+
'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
3081
3081
|
// 'Mapping Percentage': '$mappingPerc',
|
|
3082
3082
|
};
|
|
3083
3083
|
const YesNo = {
|
|
@@ -3089,7 +3089,7 @@ export async function userMetrics( req, res ) {
|
|
|
3089
3089
|
'Check Intime': '$checkIntime',
|
|
3090
3090
|
'Check OutTime': '$checkOutTime',
|
|
3091
3091
|
'Working Hours': '$workingHours',
|
|
3092
|
-
'Audited Date': { $dateToString: { format: '%Y
|
|
3092
|
+
'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
3093
3093
|
// 'Mapping Percentage': '$mappingPerc',
|
|
3094
3094
|
};
|
|
3095
3095
|
[ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?
|