tango-app-api-audit 3.4.3-alpha.0 → 3.4.3-alpha.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.4.3-alpha.0",
3
+ "version": "3.4.3-alpha.1",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -334,13 +334,13 @@ import { findOneAuditLog } from '../service/auditLog.service.js';
334
334
  // const data = await signedUrl( fetchData );
335
335
  // const mapimg = {
336
336
  // img_path: data,
337
- // img_name: indexes[1],
338
- // img_id: image[0],
337
+ // img_name: image[0],
338
+ // img_id: indexes[1],
339
339
  // };
340
340
  // files.push( {
341
341
  // img_path: data,
342
- // img_name: indexes[1],
343
- // img_id: image[0],
342
+ // img_name: image[0],
343
+ // img_id: indexes[1],
344
344
  // selected: false,
345
345
  // dropped: false,
346
346
  // count: 1,
@@ -709,7 +709,7 @@ export async function workSpace( req, res ) {
709
709
  { clientId: { $in: clientList } },
710
710
  { userId: { $eq: req.user._id } },
711
711
  { moduleType: { $eq: inputData.moduleType } },
712
- { createdAt: { $gte: dateRange.start } },
712
+ { createdAt: { $gte: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ) } },
713
713
  { createdAt: { $lte: dateRange.end } },
714
714
  ],
715
715
  },
@@ -742,6 +742,8 @@ export async function workSpace( req, res ) {
742
742
  },
743
743
  ];
744
744
 
745
+ logger.info( { moduleType: inputData.moduleType, key: inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] ), dateStart: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ), end: dateRange.end, user: req.user._id, client: clientList } );
746
+
745
747
  const userAsignAudit = [
746
748
  {
747
749
  $match: {
@@ -796,6 +798,7 @@ export async function workSpace( req, res ) {
796
798
 
797
799
  const auditUserCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( auditFiles ) : await aggregateBinaryAudit( auditFiles );
798
800
  const userIncompleteFilesCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( userIncompleteFiles ) : await aggregateBinaryAudit( userIncompleteFiles );
801
+ logger.info( { moduleType: inputData.moduleType, userIncompleteFiles: userIncompleteFilesCount } );
799
802
  const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
800
803
  const completedStoresCount = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( binarCompletedStores );
801
804
  const clientAssignedCount = await aggregateAssignAudit( clientAssign );
@@ -3809,13 +3812,13 @@ export async function getDetectionAuditFile( req, res ) {
3809
3812
  const data = await signedUrl( fetchData );
3810
3813
  const mapimg = {
3811
3814
  img_path: data,
3812
- img_name: indexes[1],
3813
- img_id: image[0],
3815
+ img_name: image[0],
3816
+ img_id: indexes[1],
3814
3817
  };
3815
3818
  files.push( {
3816
3819
  img_path: data,
3817
- img_name: indexes[1],
3818
- img_id: image[0],
3820
+ img_name: image[0],
3821
+ img_id: indexes[1],
3819
3822
  selected: false,
3820
3823
  dropped: false,
3821
3824
  count: 1,
@@ -4000,7 +4003,7 @@ export async function saveDraft( req, res ) {
4000
4003
  await insertOpenSearchData( openSearch.auditLog, logData );
4001
4004
  }
4002
4005
  await createAuditLog( inputData );
4003
- await updateOneUserEmp( userQuery, userRecord );
4006
+ await updateOneUserEmpDetection( userQuery, userRecord );
4004
4007
  await updateOneStoreEmp( storeQuery, storeRecord );
4005
4008
  return res.sendSuccess( {
4006
4009
  result: 'The file has been drafted successfully',
@@ -1,5 +1,5 @@
1
1
  import j2s from 'joi-to-swagger';
2
- import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema, getUpdatedFileSchema, getDetectionFileValid } from '../dtos/traxAudit.dtos.js';
2
+ import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema, getUpdatedFileSchema, getDetectionFileValid, saveBinarySchema, saveDraftSchema, getDraftedDataSchema } from '../dtos/traxAudit.dtos.js';
3
3
 
4
4
  export const traxAuditDocs = {
5
5
 
@@ -124,7 +124,7 @@ export const traxAuditDocs = {
124
124
  requestBody: {
125
125
  content: {
126
126
  'application/json': {
127
- schema: j2s( saveSchema ).swagger,
127
+ schema: j2s( saveBinarySchema ).swagger,
128
128
  },
129
129
  },
130
130
  },
@@ -317,4 +317,90 @@ export const traxAuditDocs = {
317
317
  },
318
318
  },
319
319
  },
320
+ '/v3/trax-audit/save': {
321
+ post: {
322
+ tags: [ 'Trax Audit' ],
323
+ description: `submit the audit file. which is store in the bucket in the json format`,
324
+ operationId: 'save',
325
+ parameters: {},
326
+ requestBody: {
327
+ content: {
328
+ 'application/json': {
329
+ schema: j2s( saveSchema ).swagger,
330
+ },
331
+ },
332
+ },
333
+ responses: {
334
+ 200: { description: 'The Audited file has been submited successfully ' },
335
+ 401: { description: 'Unauthorized User' },
336
+ 422: { description: 'Field Error' },
337
+ 500: { description: 'Server Error' },
338
+ 204: { description: 'Not Found' },
339
+ },
340
+ },
341
+ },
342
+
343
+ '/v3/trax-audit/save-draft': {
344
+ post: {
345
+ tags: [ 'Trax Audit' ],
346
+ description: `save audited file. which is save in the mongo db`,
347
+ operationId: 'save-draft',
348
+ parameters: {},
349
+ requestBody: {
350
+ content: {
351
+ 'application/json': {
352
+ schema: j2s( saveDraftSchema ).swagger,
353
+ },
354
+ },
355
+ },
356
+ responses: {
357
+ 200: { description: 'Successful' },
358
+ 401: { description: 'Unauthorized User' },
359
+ 422: { description: 'Field Error' },
360
+ 500: { description: 'Server Error' },
361
+ 204: { description: 'Not Found' },
362
+ },
363
+ },
364
+ },
365
+
366
+ '/v3/reax-audit/get-drafted-data': {
367
+ get: {
368
+ tags: [ 'Trax Audit' ],
369
+ description: 'Get a saved file via DB',
370
+ operationId: 'get-drafted-data',
371
+ parameters: [
372
+ {
373
+ in: 'query',
374
+ name: 'fileDate',
375
+ scema: j2s( getDraftedDataSchema ).swagger,
376
+ require: true,
377
+ },
378
+ {
379
+ in: 'query',
380
+ name: 'storeId',
381
+ scema: j2s( getDraftedDataSchema ).swagger,
382
+ require: true,
383
+ },
384
+ {
385
+ in: 'query',
386
+ name: 'moduleType',
387
+ scema: j2s( getDraftedDataSchema ).swagger,
388
+ require: true,
389
+ },
390
+ {
391
+ in: 'query',
392
+ name: 'userId',
393
+ scema: j2s( getDraftedDataSchema ).swagger,
394
+ require: false,
395
+ },
396
+ ],
397
+ responses: {
398
+ 200: { description: 'Successful' },
399
+ 401: { description: 'Unauthorized User' },
400
+ 422: { description: 'Field Error' },
401
+ 500: { description: 'Server Error' },
402
+ 204: { description: 'Not Found' },
403
+ },
404
+ },
405
+ },
320
406
  };
@@ -96,8 +96,6 @@ export const saveSchema = joi.object( {
96
96
  employee: joi.array().required(),
97
97
  customerCount: joi.number().required(),
98
98
  customer: joi.array().required(),
99
- moduleType: joi.string().required(),
100
- zoneName: joi.string().required(),
101
99
  } );
102
100
 
103
101
  export const saveValid = {
@@ -54,8 +54,6 @@ export const saveDraftSchema = joi.object(
54
54
  junk: joi.array().optional(),
55
55
  employeeCount: joi.number().optional(),
56
56
  employee: joi.array().optional(),
57
- customerCount: joi.number().optional(),
58
- customer: joi.array().optional(),
59
57
  retagCount: joi.number().optional(),
60
58
  retagImage: joi.array().optional(),
61
59
  },
@@ -71,7 +69,6 @@ export const getDraftedDataSchema = joi.object(
71
69
  fileDate: joi.string().required(),
72
70
  userId: joi.string().optional(),
73
71
  moduleType: joi.string().required(),
74
- zoneName: joi.string().required(),
75
72
  },
76
73
  );
77
74
 
@@ -79,7 +76,7 @@ export const getDraftedDataValid = {
79
76
  query: getDraftedDataSchema,
80
77
  };
81
78
 
82
- export const saveSchema = joi.object(
79
+ export const saveBinarySchema = joi.object(
83
80
  {
84
81
  auditId: joi.string().required(),
85
82
  storeId: joi.string().required(),
@@ -93,8 +90,8 @@ export const saveSchema = joi.object(
93
90
  },
94
91
  );
95
92
 
96
- export const saveValid = {
97
- body: saveSchema,
93
+ export const saveBinaryValid = {
94
+ body: saveBinarySchema,
98
95
  };
99
96
 
100
97
  export const workSpaceSchema = joi.object(
@@ -268,3 +265,20 @@ export const overviewTableSchema = joi.object(
268
265
  export const overviewTableValid= {
269
266
  body: overviewTableSchema,
270
267
  };
268
+
269
+ export const saveSchema = joi.object( {
270
+ auditId: joi.string().required(),
271
+ storeId: joi.string().required(),
272
+ fileDate: joi.string().required(),
273
+ auditType: joi.string().required(),
274
+ moduleType: joi.string().required(),
275
+ beforeCount: joi.number().required(),
276
+ junkCount: joi.number().required(),
277
+ junk: joi.array().required(),
278
+ employeeCount: joi.number().required(),
279
+ employee: joi.array().required(),
280
+ } );
281
+
282
+ export const saveValid = {
283
+ body: saveSchema,
284
+ };
@@ -1,27 +1,28 @@
1
1
  import { Router } from 'express';
2
2
  import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
3
- import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid } from '../dtos/traxAudit.dtos.js';
3
+ import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid, saveBinaryValid, getDraftedDataValid } from '../dtos/traxAudit.dtos.js';
4
4
  import { isExistsQueue } from '../validation/audit.validation.js';
5
5
  import { clientMetrics, getAuditFile, getDetectionAuditFile, getUpdatedFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace, saveDraft, getDraftedData, save } from '../controllers/traxAudit.controllers.js';
6
6
  import { isTraxAuditDocumentExist, validateBinaryAudit } from '../validation/traxAuditValidation.js';
7
+ import { saveDraftValid } from '../dtos/audit.dtos.js';
7
8
 
8
9
  export const traxAuditRouter = Router();
9
10
 
10
11
  // Audit Mapping
11
12
 
12
- // traxAuditRouter.get( '/get-file-detection', isAllowedSessionHandler, validate( getDetectionFileValid ), isExistsQueue, getDetectionAuditFile );
13
- // traxAuditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
14
- // traxAuditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
15
- // traxAuditRouter.post( '/save', isAllowedSessionHandler, validate( saveValid ), validateUserEmpDetection, save ); use this validateuserEMpDetection
16
- traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
13
+ traxAuditRouter.get( '/get-file-detection', isAllowedSessionHandler, validate( getDetectionFileValid ), isExistsQueue, getDetectionAuditFile );
14
+ traxAuditRouter.post( '/save', validate( saveValid ), isAllowedSessionHandler, save );
15
+ traxAuditRouter.post( '/save-draft', validate( saveDraftValid ), isAllowedSessionHandler, saveDraft );
16
+ traxAuditRouter.get( '/get-drafted-data', validate( getDraftedDataValid ), isAllowedSessionHandler, getDraftedData );
17
17
 
18
18
 
19
19
  // Y/n
20
20
  traxAuditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
21
21
  traxAuditRouter.post( '/get-updated-file', isAllowedSessionHandler, validate( getUpdatedFileValid ), isTraxAuditDocumentExist, getUpdatedFile );
22
- traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveValid ), validateBinaryAudit, saveBinary );
22
+ traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveBinaryValid ), validateBinaryAudit, saveBinary );
23
23
 
24
24
  // metrcis
25
+ traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
25
26
  traxAuditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );
26
27
  traxAuditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
27
28
  traxAuditRouter.post( '/metrics/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
@@ -34,10 +35,4 @@ traxAuditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler,
34
35
  traxAuditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
35
36
  traxAuditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
36
37
 
37
-
38
- traxAuditRouter.get( '/get-file-detection', isAllowedSessionHandler, validate( getDetectionFileValid ), isExistsQueue, getDetectionAuditFile );
39
- traxAuditRouter.post( '/save', isAllowedSessionHandler, save );
40
- traxAuditRouter.post( '/save-draft', isAllowedSessionHandler, saveDraft );
41
- traxAuditRouter.get( '/get-drafted-data', isAllowedSessionHandler, getDraftedData );
42
-
43
38
  export default traxAuditRouter;
@@ -1,7 +1,9 @@
1
1
  import userEmpDetectionModel from 'tango-api-schema/schema/userEmpDetection.model.js';
2
+ import { logger } from 'tango-app-api-middleware';
2
3
 
3
4
 
4
5
  export function aggregateUserEmpDetection( query ) {
6
+ logger.info( { seelevt: 'yryruteretwyyyyyyyyyyyyyyyyyyyyyyyyyyyyewe' } );
5
7
  return userEmpDetectionModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
6
8
  }
7
9