tango-app-api-audit 3.3.0-alpha.24 → 3.3.0-alpha.25

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.3.0-alpha.24",
3
+ "version": "3.3.0-alpha.25",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "nodemon": "^3.1.3",
26
26
  "swagger-ui-express": "^5.0.1",
27
27
  "tango-api-schema": "^2.0.159",
28
- "tango-app-api-middleware": "^3.1.32",
28
+ "tango-app-api-middleware": "^3.1.33",
29
29
  "winston": "^3.13.0",
30
30
  "winston-daily-rotate-file": "^5.0.0"
31
31
  },
@@ -3,11 +3,11 @@ import {
3
3
  download,
4
4
  fileUpload,
5
5
  getJsonFileData,
6
- getUTC,
7
6
  insertOpenSearchData,
8
7
  listFileByPath,
9
8
  listFileWithoutLimit,
10
9
  signedUrl,
10
+ getDate, getDateWithCustomizeTime,
11
11
  } from 'tango-app-api-middleware';
12
12
  import {
13
13
  aggregateUserAudit,
@@ -194,7 +194,7 @@ export async function getAuditFile( req, res ) {
194
194
  const bucket = JSON.parse( process.env.BUCKET );
195
195
  const openSearch = JSON.parse( process.env.OPENSEARCH );
196
196
  const inputData = req.query;
197
- const data = await getUTC( new Date(), new Date() );
197
+ const data = await getDate( new Date(), new Date() );
198
198
  const start = data.start;
199
199
  const end = data.end;
200
200
  const fetchData = {};
@@ -742,7 +742,7 @@ export async function workSpace( req, res ) {
742
742
  const offset = inputData.offset ?
743
743
  ( inputData.offset - 1 ) * limit :
744
744
  0;
745
- const dateRange = await getUTC( new Date(), new Date() );
745
+ const dateRange = await getDate( new Date(), new Date() );
746
746
  const filter =[
747
747
  { status: { $in: [ 'active', 'hold' ] } },
748
748
  { 'auditConfigs.audit': { $eq: true } },
@@ -1442,8 +1442,8 @@ export async function userAuditHistory( req, res ) {
1442
1442
  const userId = inputData.userId? new mongoose.Types.ObjectId( inputData.userId ) : req.user._id;
1443
1443
  const limit = inputData.limit || 10;
1444
1444
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
1445
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1446
-
1445
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1446
+ const dateRangeCreatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1447
1447
  let filter = [
1448
1448
  { userId: { $eq: userId } },
1449
1449
  ];
@@ -1455,8 +1455,8 @@ export async function userAuditHistory( req, res ) {
1455
1455
  );
1456
1456
  } else {
1457
1457
  filter.push(
1458
- { createdAt: { $gte: dateRange.start } },
1459
- { createdAt: { $lte: dateRange.end } },
1458
+ { createdAt: { $gte: dateRangeCreatedAt.start } },
1459
+ { createdAt: { $lte: dateRangeCreatedAt.end } },
1460
1460
  );
1461
1461
  }
1462
1462
 
@@ -1697,7 +1697,7 @@ export async function clientMetrics( req, res ) {
1697
1697
  const inputData = req.body;
1698
1698
  const limit = inputData.limit || 10;
1699
1699
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
1700
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1700
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1701
1701
  let filter = [
1702
1702
  { fileDateISO: { $gte: dateRange.start } },
1703
1703
  { fileDateISO: { $lte: dateRange.end } },
@@ -1922,7 +1922,7 @@ export async function storeMetrics( req, res ) {
1922
1922
  const inputData = req.body;
1923
1923
  const limit = inputData.limit || 10;
1924
1924
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
1925
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1925
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1926
1926
  let filter = [
1927
1927
  { fileDateISO: { $gte: dateRange.start } },
1928
1928
  { fileDateISO: { $lte: dateRange.end } },
@@ -2208,12 +2208,13 @@ export async function userMetrics( req, res ) {
2208
2208
  const inputData = req.body;
2209
2209
  const limit = inputData.limit || 10;
2210
2210
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
2211
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2211
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2212
+ const dateRangeUpdatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2212
2213
  let filter = [];
2213
2214
  if ( inputData.dateType == 'auditedDate' ) {
2214
2215
  filter.push(
2215
- { updatedAt: { $gte: dateRange.start } },
2216
- { updatedAt: { $lte: dateRange.end } },
2216
+ { updatedAt: { $gte: dateRangeUpdatedAt.start } },
2217
+ { updatedAt: { $lte: dateRangeUpdatedAt.end } },
2217
2218
 
2218
2219
  );
2219
2220
  } else {
@@ -2479,7 +2480,7 @@ export async function pendingSummaryTable( req, res ) {
2479
2480
  const inputData = req.body;
2480
2481
  const limit = inputData.limit || 10;
2481
2482
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
2482
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2483
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2483
2484
  let filters =[
2484
2485
  { fileDateISO: { $gte: dateRange.start } },
2485
2486
  { fileDateISO: { $lte: dateRange.end } },
@@ -2671,7 +2672,7 @@ export async function overAllAuditSummary( req, res ) {
2671
2672
  reAuditCompleted: 0,
2672
2673
 
2673
2674
  };
2674
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2675
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2675
2676
  let filters =[
2676
2677
  { fileDateISO: { $gte: dateRange.start } },
2677
2678
  { fileDateISO: { $lte: dateRange.end } },
@@ -2936,7 +2937,7 @@ export async function overViewCard( req, res ) {
2936
2937
  pendingCount: 0,
2937
2938
  };
2938
2939
 
2939
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2940
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2940
2941
  let filters =[
2941
2942
  { fileDateISO: { $gte: dateRange.start } },
2942
2943
  { fileDateISO: { $lte: dateRange.end } },
@@ -3021,7 +3022,7 @@ export async function summarySplit( req, res ) {
3021
3022
  reAuditCompleted: 0,
3022
3023
  };
3023
3024
 
3024
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
3025
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
3025
3026
  let filters =[
3026
3027
  { fileDateISO: { $gte: dateRange.start } },
3027
3028
  { fileDateISO: { $lte: dateRange.end } },
@@ -3137,7 +3138,7 @@ export async function overviewTable( req, res ) {
3137
3138
  const inputData = req.body;
3138
3139
  const limit = inputData.limit || 10;
3139
3140
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
3140
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
3141
+ const dateRange = await getDate( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
3141
3142
  let filters =[
3142
3143
  { fileDateISO: { $gte: dateRange.start } },
3143
3144
  { fileDateISO: { $lte: dateRange.end } },