tango-app-api-audit 3.4.11-alpha.22 → 3.4.11-alpha.24

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.4.11-alpha.22",
3
+ "version": "3.4.11-alpha.24",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2320,11 +2320,17 @@ export async function userMetrics( req, res ) {
2320
2320
  userId: 1,
2321
2321
  fileDate: 1,
2322
2322
  startTime: 1,
2323
- endTime: 1,
2323
+ endTime: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$endTime', '$$REMOVE' ] },
2324
2324
  totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
2325
2325
  beforeCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$beforeCount', 0 ] },
2326
2326
  afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
2327
2327
  createdAt: 1,
2328
+ // to: '$createdAt',
2329
+ },
2330
+ },
2331
+ {
2332
+ $sort: {
2333
+ endTime: -1,
2328
2334
  },
2329
2335
  },
2330
2336
  {
@@ -2336,8 +2342,9 @@ export async function userMetrics( req, res ) {
2336
2342
  beforeCount: { $sum: '$beforeCount' },
2337
2343
  afterCount: { $sum: '$afterCount' },
2338
2344
  checkIntime: { $first: '$startTime' },
2339
- checkOutTime: { $last: '$endTime' },
2345
+ checkOutTime: { $first: '$endTime' },
2340
2346
  createdAt: { $first: '$createdAt' },
2347
+ to: { $last: '$createdAt' },
2341
2348
 
2342
2349
  },
2343
2350
  },
@@ -2373,6 +2380,7 @@ export async function userMetrics( req, res ) {
2373
2380
  $divide: [ { $subtract: [ '$checkOutTime', '$checkIntime' ] }, 1000 ],
2374
2381
  },
2375
2382
  createdAt: 1,
2383
+ to: 1,
2376
2384
  },
2377
2385
  },
2378
2386
  {
@@ -2389,6 +2397,7 @@ export async function userMetrics( req, res ) {
2389
2397
  minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
2390
2398
  seconds: { $mod: [ '$differenceInSeconds', 60 ] },
2391
2399
  createdAt: 1,
2400
+ to: 1,
2392
2401
  },
2393
2402
  },
2394
2403
  {
@@ -2424,6 +2433,7 @@ export async function userMetrics( req, res ) {
2424
2433
  },
2425
2434
  },
2426
2435
  createdAt: 1,
2436
+ to: 1,
2427
2437
  },
2428
2438
  },
2429
2439
  {
@@ -2442,6 +2452,7 @@ export async function userMetrics( req, res ) {
2442
2452
  $concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
2443
2453
  },
2444
2454
  createdAt: 1,
2455
+ to: 1,
2445
2456
  },
2446
2457
  },
2447
2458
  {
@@ -2496,6 +2507,7 @@ export async function userMetrics( req, res ) {
2496
2507
  },
2497
2508
  workingHours: 1,
2498
2509
  createdAt: 1,
2510
+ to: 1,
2499
2511
  },
2500
2512
  },
2501
2513
  ];
@@ -4734,6 +4746,7 @@ export async function auditViewLogs( req, res ) {
4734
4746
  },
4735
4747
  };
4736
4748
  break;
4749
+ case 'uniform-detection':
4737
4750
  case 'mobile-detection':
4738
4751
  logsQuery = {
4739
4752
  'size': 100,
@@ -4535,39 +4535,42 @@ export async function save( req, res ) {
4535
4535
  if ( !getFilePath ) {
4536
4536
  return res.sendError( ' SQS is not sent due to Inserted Data is not there', 400 );
4537
4537
  }
4538
+ const [ getStore, getClient ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: inputData.clientId }, { clientName: 1 } ) ] );
4539
+
4538
4540
  const tempId=[];
4539
4541
  if ( inputData.employeeCount > 0 ) {
4540
4542
  for ( let i =0; i<inputData?.employee.length; i++ ) {
4541
4543
  tempId.push( inputData?.employee[i].img_id );
4542
4544
  }
4543
- }
4544
- const [ getStore, getClient ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: inputData.clientId }, { clientName: 1 } ) ] );
4545
- const sqsProduceQueue = {
4546
- QueueUrl: `${sqs.url}${sqs.uniformOutput}`,
4547
- MessageBody: JSON.stringify( {
4548
- storeId: inputData.storeId,
4549
- storeName: getStore?.storeName,
4550
- fileDate: inputData.fileDate,
4551
- moduleType: inputData.moduleType,
4552
- inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
4553
- tempId: tempId,
4554
- count: inputData.employeeCount,
4555
- folderPath: getFilePath?.sqs?.Body?.folderPath,
4556
- } ),
4557
- };
4558
- const sqsQueue = await sendMessageToQueue(
4559
- sqsProduceQueue.QueueUrl,
4560
- sqsProduceQueue.MessageBody,
4561
- );
4562
4545
 
4563
- if ( sqsQueue.statusCode ) {
4564
- logger.error( {
4565
- error: `${sqsQueue}`,
4566
- type: 'UPLOAD_ERROR',
4567
- } );
4568
- return res.sendError( 'SQS not sent', 500 );
4546
+ const sqsProduceQueue = {
4547
+ QueueUrl: `${sqs.url}${sqs.uniformOutput}`,
4548
+ MessageBody: JSON.stringify( {
4549
+ storeId: inputData.storeId,
4550
+ storeName: getStore?.storeName,
4551
+ fileDate: inputData.fileDate,
4552
+ moduleType: inputData.moduleType,
4553
+ inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
4554
+ tempId: tempId,
4555
+ count: inputData.employeeCount,
4556
+ folderPath: getFilePath?.sqs?.Body?.folderPath,
4557
+ } ),
4558
+ };
4559
+ const sqsQueue = await sendMessageToQueue(
4560
+ sqsProduceQueue.QueueUrl,
4561
+ sqsProduceQueue.MessageBody,
4562
+ );
4563
+
4564
+ if ( sqsQueue.statusCode ) {
4565
+ logger.error( {
4566
+ error: `${sqsQueue}`,
4567
+ type: 'UPLOAD_ERROR',
4568
+ } );
4569
+ return res.sendError( 'SQS not sent', 500 );
4570
+ }
4569
4571
  }
4570
4572
 
4573
+
4571
4574
  // trax output in open serach
4572
4575
  const output = {
4573
4576
  clientId: inputData.clientId,
@@ -1,4 +1,4 @@
1
- import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, reTriggerValidSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema, auditImageValidSchema, pendingSummaryTableSchema, overviewTableSchema } from '../dtos/audit.dtos.js';
1
+ import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, reTriggerValidSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema, auditImageValidSchema, pendingSummaryTableSchema, overviewTableSchema, auditViewlogSchema } from '../dtos/audit.dtos.js';
2
2
  import j2s from 'joi-to-swagger';
3
3
 
4
4
  export const auditDocs = {
@@ -544,6 +544,47 @@ export const auditDocs = {
544
544
  },
545
545
  },
546
546
  },
547
+ '/v3/audit/audit-view-logs': {
548
+ get: {
549
+ tags: [ 'Audit Mapping' ],
550
+ description: `Get log for a store audit details`,
551
+ operationId: 'audit-view-logs',
552
+ parameters: [
553
+ {
554
+ in: 'query',
555
+ name: 'fileDate',
556
+ scema: j2s( auditViewlogSchema ).swagger,
557
+ require: true,
558
+ },
559
+ {
560
+ in: 'query',
561
+ name: 'storeId',
562
+ scema: j2s( auditViewlogSchema ).swagger,
563
+ require: true,
564
+ },
565
+ {
566
+ in: 'query',
567
+ name: 'moduleType',
568
+ scema: j2s( auditViewlogSchema ).swagger,
569
+ require: true,
570
+ },
571
+ {
572
+ in: 'query',
573
+ name: 'zoneName',
574
+ scema: j2s( auditViewlogSchema ).swagger,
575
+ require: false,
576
+ },
577
+ ],
578
+ responses: {
579
+ 200: { description: 'Successful' },
580
+ 401: { description: 'Unauthorized User' },
581
+ 422: { description: 'Field Error' },
582
+ 500: { description: 'Server Error' },
583
+ 204: { description: 'Not Found' },
584
+ },
585
+
586
+ },
587
+ },
547
588
  '/v3/audit/get-user-credit': {
548
589
  get: {
549
590
  tags: [ 'Audit User Wallet' ],
@@ -239,6 +239,17 @@ export const overviewTableValid = {
239
239
  body: overviewTableSchema,
240
240
  };
241
241
 
242
+ export const auditViewlogSchema = joi.object( {
243
+ fileDate: joi.string().required(),
244
+ storeId: joi.string().required(),
245
+ moduleType: joi.string().required(),
246
+ zoneName: joi.string().optional(),
247
+ } );
248
+
249
+ export const auditViewLogValid = {
250
+ query: auditViewlogSchema,
251
+ };
252
+
242
253
  export const overAllAuditSummarySchema = joi.object( {
243
254
  fromDate: joi.string().required(),
244
255
  toDate: joi.string().required(),
@@ -2,7 +2,7 @@ import express from 'express';
2
2
  import { isAuditDocumentExist, isAuditInputFolderExist, isAuditUser, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
3
3
  import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
4
4
  import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace, getUserAuditCount, getUserAuditCountMTD, auditViewLogs, getUserCredit } from '../controllers/audit.controllers.js';
5
- import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid } from '../dtos/audit.dtos.js';
5
+ import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid, auditViewLogValid } from '../dtos/audit.dtos.js';
6
6
 
7
7
  export const auditRouter = express.Router();
8
8
 
@@ -42,5 +42,5 @@ auditRouter.get( '/get-user-audit-count', isAllowedSessionHandler, getUserAuditC
42
42
  auditRouter.get( '/get-user-audit-count-mtd', isAllowedSessionHandler, getUserAuditCountMTD );
43
43
 
44
44
  // audit log
45
- auditRouter.get( '/audit-view-logs', isAllowedSessionHandler, auditViewLogs );
45
+ auditRouter.get( '/audit-view-logs', isAllowedSessionHandler, validate( auditViewLogValid ), auditViewLogs );
46
46
  export default auditRouter;