tango-app-api-audit 3.3.0 → 3.3.1

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",
3
+ "version": "3.3.1",
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,12 @@ 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
+ getUTC,
11
12
  } from 'tango-app-api-middleware';
12
13
  import {
13
14
  aggregateUserAudit,
@@ -194,7 +195,9 @@ export async function getAuditFile( req, res ) {
194
195
  const bucket = JSON.parse( process.env.BUCKET );
195
196
  const openSearch = JSON.parse( process.env.OPENSEARCH );
196
197
  const inputData = req.query;
197
- const data = await getUTC( new Date(), new Date() );
198
+ const data = await getDate( new Date(), new Date() );
199
+ logger.info( { data: data, function: 'data', newDate: new Date() } );
200
+ logger.info( { userId: req.user._id, queueName: inputData.queueName, moduleType: inputData.moduleType } );
198
201
  const start = data.start;
199
202
  const end = data.end;
200
203
  const fetchData = {};
@@ -221,6 +224,7 @@ export async function getAuditFile( req, res ) {
221
224
  ];
222
225
 
223
226
  const userDetails = await aggregateUserAudit( userQuery );
227
+ logger.info( { userDetails: userDetails, function: 'userDetails' } );
224
228
  const auditStatus =
225
229
  userDetails && userDetails.length > 0 ? userDetails[0].auditStatus : null;
226
230
  switch ( auditStatus ) {
@@ -240,7 +244,7 @@ export async function getAuditFile( req, res ) {
240
244
  const userAssign = await aggregateAssignAudit( query );
241
245
  if ( userAssign.length > 0 ) {
242
246
  logger.info( 'Hit in user assign', { inputData } );
243
- userAssign[0].fileType == 'Audit' ?
247
+ userAssign[0].auditType == 'Audit' ?
244
248
  ( msg = {
245
249
  store_id: userAssign[0].storeId,
246
250
  curr_date: userAssign[0].fileDate,
@@ -250,7 +254,7 @@ export async function getAuditFile( req, res ) {
250
254
  ( msg = {
251
255
  store_id: userAssign[0].storeId,
252
256
  curr_date: userAssign[0].fileDate,
253
- audit_type: userAssign[0].fileType,
257
+ audit_type: userAssign[0].auditType,
254
258
  total_count: userAssign[0].fileCount,
255
259
  zone_id: userAssign[0].zoneName,
256
260
  } );
@@ -1143,6 +1147,7 @@ export async function saveDraft( req, res ) {
1143
1147
  const storeQuery = {
1144
1148
  storeId: inputData.storeId,
1145
1149
  fileDate: inputData.fileDate,
1150
+ zoneName: inputData.zoneName,
1146
1151
  };
1147
1152
 
1148
1153
  let storeRecord = {
@@ -1442,7 +1447,7 @@ export async function userAuditHistory( req, res ) {
1442
1447
  const limit = inputData.limit || 10;
1443
1448
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
1444
1449
  const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1445
-
1450
+ const dateRangeCreatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1446
1451
  let filter = [
1447
1452
  { userId: { $eq: userId } },
1448
1453
  ];
@@ -1454,8 +1459,8 @@ export async function userAuditHistory( req, res ) {
1454
1459
  );
1455
1460
  } else {
1456
1461
  filter.push(
1457
- { createdAt: { $gte: dateRange.start } },
1458
- { createdAt: { $lte: dateRange.end } },
1462
+ { createdAt: { $gte: dateRangeCreatedAt.start } },
1463
+ { createdAt: { $lte: dateRangeCreatedAt.end } },
1459
1464
  );
1460
1465
  }
1461
1466
 
@@ -2208,11 +2213,12 @@ export async function userMetrics( req, res ) {
2208
2213
  const limit = inputData.limit || 10;
2209
2214
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
2210
2215
  const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2216
+ const dateRangeUpdatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2211
2217
  let filter = [];
2212
2218
  if ( inputData.dateType == 'auditedDate' ) {
2213
2219
  filter.push(
2214
- { updatedAt: { $gte: dateRange.start } },
2215
- { updatedAt: { $lte: dateRange.end } },
2220
+ { updatedAt: { $gte: dateRangeUpdatedAt.start } },
2221
+ { updatedAt: { $lte: dateRangeUpdatedAt.end } },
2216
2222
 
2217
2223
  );
2218
2224
  } else {
@@ -12,7 +12,7 @@ auditRouter.get( '/clients', isAllowedSessionHandler, validate( clientValid ), c
12
12
  auditRouter.post( '/audit-stores', isAllowedSessionHandler, validate( auditStoreValid ), auditStoreList );
13
13
  auditRouter.get( '/tango-users', isAllowedSessionHandler, auditUserList );
14
14
 
15
- // Audit Mapping
15
+ // Audit Mapping
16
16
  auditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
17
17
  auditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
18
18
  auditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );