tango-app-api-audit 1.0.7 → 1.0.9
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 +2 -1
- package/src/controllers/audit.controllers.js +37 -31
- package/src/controllers/auditMetrics.controllers.js +95 -8
- package/src/docs/audit.docs.js +42 -1
- package/src/docs/auditMetrics.docs.js +23 -1
- package/src/dtos/audit.dtos.js +7 -7
- package/src/dtos/auditMetrics.dtos.js +13 -5
- package/src/routes/audit.routes.js +3 -3
- package/src/service/storeAudit.service.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"express": "^4.19.2",
|
|
20
20
|
"handlebars": "^4.7.8",
|
|
21
21
|
"joi-to-swagger": "^6.2.0",
|
|
22
|
+
"lodash": "^4.17.21",
|
|
22
23
|
"mongodb": "^6.7.0",
|
|
23
24
|
"nodemon": "^3.1.3",
|
|
24
25
|
"swagger-ui-express": "^5.0.1",
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { chunkArray, getJsonFileData, getOpenSearchData, getUTC, insertOpenSearchData, listFileByPath, listFileWithoutLimit, signedUrl } from 'tango-app-api-middleware';
|
|
1
|
+
import { chunkArray, download, getJsonFileData, getOpenSearchData, getUTC, insertOpenSearchData, listFileByPath, listFileWithoutLimit, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import { aggregateUserAudit, createUserAudit, findOneUserAudit, updateOneUserAudit } from '../service/userAudit.service.js';
|
|
3
3
|
import { aggregateAssignAudit, updateOneAssignAudit } from '../service/assignAudit.service.js';
|
|
4
4
|
import { findOneUser } from '../service/user.service.js';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import { aggregateClient } from '../service/client.service.js';
|
|
7
7
|
import { logger } from 'tango-app-api-middleware';
|
|
8
|
-
import { sqsReceive } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
9
|
-
import { createStoreAudit, updateOneStoreAudit } from '../service/storeAudit.service.js';
|
|
8
|
+
import { listQueue, sqsReceive } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
9
|
+
import { aggregateStoreAudit, createStoreAudit, updateOneStoreAudit } from '../service/storeAudit.service.js';
|
|
10
|
+
import { aggregateAuditClientData } from '../service/auditClientData.service.js';
|
|
11
|
+
import _ from 'lodash';
|
|
10
12
|
|
|
11
13
|
export async function getAuditFile( req, res ) {
|
|
12
14
|
try {
|
|
@@ -448,17 +450,19 @@ export const mapFunction = async ( chunk, filter ) => {
|
|
|
448
450
|
return temp;
|
|
449
451
|
};
|
|
450
452
|
|
|
451
|
-
export async function
|
|
453
|
+
export async function workSpace( req, res ) {
|
|
452
454
|
try {
|
|
453
455
|
const inputData = req.query;
|
|
454
|
-
const
|
|
456
|
+
const limit = inputData.limit || 10;
|
|
457
|
+
const offset =inputData.offset? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
458
|
+
const dateRange = await getUTC( new Date(), new Date() );
|
|
455
459
|
|
|
456
460
|
const temp = [];
|
|
457
461
|
const clientQuery = [
|
|
458
462
|
{
|
|
459
463
|
$match: {
|
|
460
464
|
$and: [
|
|
461
|
-
{
|
|
465
|
+
{ status: { $in: [ 'active', 'hold' ] } },
|
|
462
466
|
{ 'auditConfigs.audit': { $eq: true } },
|
|
463
467
|
],
|
|
464
468
|
},
|
|
@@ -471,7 +475,7 @@ export async function getQueueDetailList( req, res ) {
|
|
|
471
475
|
},
|
|
472
476
|
];
|
|
473
477
|
|
|
474
|
-
if ( inputData.searchValue ) {
|
|
478
|
+
if ( inputData.searchValue&& inputData.searchValue!== '' ) {
|
|
475
479
|
clientQuery.push( {
|
|
476
480
|
$match: {
|
|
477
481
|
$or: [
|
|
@@ -482,16 +486,16 @@ export async function getQueueDetailList( req, res ) {
|
|
|
482
486
|
} );
|
|
483
487
|
}
|
|
484
488
|
const count = await aggregateClient( clientQuery );
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
489
|
+
logger.info( { count: count } );
|
|
490
|
+
if ( count?.length == 0 ) {
|
|
491
|
+
return res.sendError( 'No Data Found', 204 );
|
|
488
492
|
}
|
|
489
493
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return res.sendError( 'No Data Found', 204 );
|
|
494
|
+
if ( inputData.limit && !inputData.isExport ) {
|
|
495
|
+
clientQuery.push( { $skip: offset }, { $limit: limit } );
|
|
493
496
|
}
|
|
494
497
|
|
|
498
|
+
const clientDetails = await aggregateClient( clientQuery );
|
|
495
499
|
const clientList = clientDetails.map( ( i ) => i.clientId );
|
|
496
500
|
const query = [
|
|
497
501
|
{
|
|
@@ -519,7 +523,7 @@ export async function getQueueDetailList( req, res ) {
|
|
|
519
523
|
},
|
|
520
524
|
];
|
|
521
525
|
|
|
522
|
-
const fileDate = dayjs(
|
|
526
|
+
const fileDate = dayjs( dateRange.start ).subtract( 1, 'days' );
|
|
523
527
|
|
|
524
528
|
const completedFiles = [
|
|
525
529
|
{
|
|
@@ -534,7 +538,7 @@ export async function getQueueDetailList( req, res ) {
|
|
|
534
538
|
$project: {
|
|
535
539
|
clientId: 1,
|
|
536
540
|
completed: {
|
|
537
|
-
$cond: [ { $eq: [ '$
|
|
541
|
+
$cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ],
|
|
538
542
|
},
|
|
539
543
|
},
|
|
540
544
|
},
|
|
@@ -560,8 +564,8 @@ export async function getQueueDetailList( req, res ) {
|
|
|
560
564
|
$match: {
|
|
561
565
|
$and: [
|
|
562
566
|
{ clientId: { $in: clientList } },
|
|
563
|
-
{ createdAt: { $gte:
|
|
564
|
-
{ createdAt: { $lte:
|
|
567
|
+
{ createdAt: { $gte: dateRange.start } },
|
|
568
|
+
{ createdAt: { $lte: dateRange.end } },
|
|
565
569
|
],
|
|
566
570
|
},
|
|
567
571
|
},
|
|
@@ -569,7 +573,7 @@ export async function getQueueDetailList( req, res ) {
|
|
|
569
573
|
$project: {
|
|
570
574
|
clientId: 1,
|
|
571
575
|
pending: {
|
|
572
|
-
$cond: [ { $or: [ { $in: [ '$auditStatus', [ 'inprogress', 'drafted' ] ] }
|
|
576
|
+
$cond: [ { $or: [ { $in: [ '$auditStatus', [ 'inprogress', 'drafted' ] ] } ] }, 1, 0 ],
|
|
573
577
|
},
|
|
574
578
|
},
|
|
575
579
|
},
|
|
@@ -599,8 +603,8 @@ export async function getQueueDetailList( req, res ) {
|
|
|
599
603
|
$and: [
|
|
600
604
|
{ clientId: { $in: clientList } },
|
|
601
605
|
{ userId: { $eq: inputData.userId } },
|
|
602
|
-
{ createdAt: { $gte:
|
|
603
|
-
{ createdAt: { $lte:
|
|
606
|
+
{ createdAt: { $gte: dateRange.start } },
|
|
607
|
+
{ createdAt: { $lte: dateRange.end } },
|
|
604
608
|
],
|
|
605
609
|
},
|
|
606
610
|
},
|
|
@@ -686,14 +690,14 @@ export async function getQueueDetailList( req, res ) {
|
|
|
686
690
|
},
|
|
687
691
|
];
|
|
688
692
|
|
|
689
|
-
const auditDetails = await
|
|
690
|
-
const auditCount = await
|
|
691
|
-
const draftedCount = await
|
|
692
|
-
const CompletedCount = await
|
|
693
|
+
const auditDetails = await aggregateAuditClientData( query );
|
|
694
|
+
const auditCount = await aggregateUserAudit( auditFiles );
|
|
695
|
+
const draftedCount = await aggregateUserAudit( draftedFiles );
|
|
696
|
+
const CompletedCount = await aggregateStoreAudit( completedFiles );
|
|
693
697
|
|
|
694
|
-
const clientAssignresult = await
|
|
698
|
+
const clientAssignresult = await aggregateAssignAudit( clientAssign );
|
|
695
699
|
|
|
696
|
-
const userAsignCount = await
|
|
700
|
+
const userAsignCount = await aggregateAssignAudit( userAsign );
|
|
697
701
|
const mergeAll = _.merge( _.keyBy( clientDetails, 'clientId' ), _.keyBy( auditCount, 'clientId' ), _.keyBy( draftedCount, 'clientId' ), _.keyBy( clientAssignresult, 'clientId' ) );
|
|
698
702
|
const finalResult = _.values( mergeAll );
|
|
699
703
|
const merge = _.values( _.merge( _.keyBy( finalResult, 'clientId' ), _.keyBy( auditDetails, 'clientId' ), _.keyBy( userAsignCount, 'clientId' ), _.keyBy( CompletedCount, 'clientId' ) ) );
|
|
@@ -705,13 +709,13 @@ export async function getQueueDetailList( req, res ) {
|
|
|
705
709
|
const pending = await listQueue( merge[i].queueName );
|
|
706
710
|
if ( !pending.statusCode ) {
|
|
707
711
|
temp.push( {
|
|
708
|
-
|
|
709
|
-
|
|
712
|
+
clientId: merge[i].clientId,
|
|
713
|
+
clientName: merge[i].clientName,
|
|
710
714
|
completedCount: merge[i].completedCount ? Number( merge[i].completedCount ) : 0,
|
|
711
715
|
pendingByQueue: Number( pending ),
|
|
712
716
|
pendingByUser: ( merge[i].pendingCount >= 0 ) ? Number( merge[i].pendingCount )+( merge[i].ClientAsignedCount ? Number( merge[i].ClientAsignedCount ) : 0 ) : 0,
|
|
713
717
|
totalCount: merge[i].totalFilesCount,
|
|
714
|
-
|
|
718
|
+
queueName: merge[i].queueName,
|
|
715
719
|
isDraft: merge[i].isDrafted ? merge[i].isDrafted : false,
|
|
716
720
|
isEnable: Number( pending ) > 0 || merge[i].isDrafted || ( merge[i].asignedCount && merge[i].asignedCount > 0 ) || ( merge[i].inprogressCount && merge[i].inprogressCount > 0 ) ? true : false,
|
|
717
721
|
completedRatio: merge[i].totalFilesCount ? merge[i].completedCount ? Math.round( ( Number( merge[i].completedCount ) / Number( merge[i].totalFilesCount ) ) * 100 ) : 0 : 0,
|
|
@@ -721,7 +725,7 @@ export async function getQueueDetailList( req, res ) {
|
|
|
721
725
|
}
|
|
722
726
|
}
|
|
723
727
|
|
|
724
|
-
if ( inputData.
|
|
728
|
+
if ( inputData.isExport ) {
|
|
725
729
|
const exportdata = [];
|
|
726
730
|
temp.forEach( ( element ) => {
|
|
727
731
|
exportdata.push( {
|
|
@@ -741,7 +745,9 @@ export async function getQueueDetailList( req, res ) {
|
|
|
741
745
|
return res.sendSuccess( { result: temp, count: count.length, totalStores: totalStores } );
|
|
742
746
|
}
|
|
743
747
|
} catch ( error ) {
|
|
744
|
-
|
|
748
|
+
const err = error.message || 'Internal Server Error';
|
|
749
|
+
logger.info( { error: error, message: req.query, function: 'workSpace' } );
|
|
750
|
+
return res.sendError( err, 500 );
|
|
745
751
|
}
|
|
746
752
|
}
|
|
747
753
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { download, getUTC, logger } from 'tango-app-api-middleware';
|
|
2
2
|
import { aggregateAuditClientData } from '../service/auditClientData.service.js';
|
|
3
|
+
import { aggregateUserAudit } from '../service/userAudit.service.js';
|
|
4
|
+
import mongoose from 'mongoose';
|
|
3
5
|
// import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
4
6
|
|
|
5
7
|
|
|
@@ -15,13 +17,98 @@ export async function getAuditImageList( req, res ) {
|
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export async function userAuditHistory( req, res ) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
try {
|
|
21
|
+
const inputData = req.body;
|
|
22
|
+
const userId = inputData.userId || req.user._id;
|
|
23
|
+
const limit = inputData.limit || 10;
|
|
24
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
25
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
26
|
+
let filter = [
|
|
27
|
+
|
|
28
|
+
{ userId: { $eq: new mongoose.Types.ObjectId( userId ) } },
|
|
29
|
+
|
|
30
|
+
];
|
|
31
|
+
if ( inputData.fileType == 'fileDate' ) {
|
|
32
|
+
filter.push(
|
|
33
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
34
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
35
|
+
);
|
|
36
|
+
} else {
|
|
37
|
+
filter.push(
|
|
38
|
+
{ createdAt: { $gte: dateRange.start } },
|
|
39
|
+
{ createdAt: { $lte: dateRange.end } },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const query = [
|
|
44
|
+
{
|
|
45
|
+
$match: {
|
|
46
|
+
$and: filter,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
52
|
+
query.push( {
|
|
53
|
+
$match: {
|
|
54
|
+
$or: [
|
|
55
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
56
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
57
|
+
],
|
|
58
|
+
|
|
59
|
+
},
|
|
60
|
+
} );
|
|
61
|
+
}
|
|
62
|
+
if ( inputData.sortColumnName ) {
|
|
63
|
+
const sortBy = inputData.sortBy || -1;
|
|
64
|
+
query.push( {
|
|
65
|
+
$sort: { [inputData.sortColumName]: sortBy },
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
query.push( {
|
|
71
|
+
$project: {
|
|
72
|
+
storeId: 1,
|
|
73
|
+
storeName: '$storeId',
|
|
74
|
+
auditType: 1,
|
|
75
|
+
beforeCount: 1,
|
|
76
|
+
afterCount: 1,
|
|
77
|
+
accuracy: { $round: [
|
|
78
|
+
{
|
|
79
|
+
$divide: [ { $multiply: [ '$beforeCount', { $ifNull: [ '$afterCount', 0 ] } ] }, 100 ],
|
|
80
|
+
}, 2,
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
startTime: 1,
|
|
84
|
+
endTime: 1,
|
|
85
|
+
timeSpent: { $round: [
|
|
86
|
+
{ $divide: [ '$timeSpent', 60 ] }, 2,
|
|
87
|
+
] },
|
|
88
|
+
auditStatus: 1,
|
|
89
|
+
createdAt: 1,
|
|
90
|
+
},
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
const count = await aggregateUserAudit( query );
|
|
94
|
+
if ( count.length == 0 ) {
|
|
95
|
+
return res.sendError( 'No Data Found', 204 );
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
query.push( {
|
|
99
|
+
$skip: offset,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
$limit: limit,
|
|
103
|
+
} );
|
|
104
|
+
const result = await aggregateUserAudit( query );
|
|
105
|
+
|
|
106
|
+
return res.sendSuccess( { result: result } );
|
|
107
|
+
} catch ( error ) {
|
|
108
|
+
const err = error.message || 'Internal Server Error';
|
|
109
|
+
logger.info( { error: error, message: req.body, function: 'userAuditHistory' } );
|
|
110
|
+
return res.sendError( err, 500 );
|
|
111
|
+
}
|
|
25
112
|
}
|
|
26
113
|
|
|
27
114
|
export async function storeMetrics( req, res ) {
|
|
@@ -347,7 +434,7 @@ export async function clientMetrics( req, res ) {
|
|
|
347
434
|
},
|
|
348
435
|
},
|
|
349
436
|
];
|
|
350
|
-
if ( inputData.searchValue ) {
|
|
437
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
351
438
|
query.push( {
|
|
352
439
|
$match: {
|
|
353
440
|
$or: [
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema } from '../dtos/audit.dtos.js';
|
|
1
|
+
import { getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
|
|
2
2
|
import j2s from 'joi-to-swagger';
|
|
3
3
|
|
|
4
4
|
export const auditDocs = {
|
|
@@ -108,4 +108,45 @@ export const auditDocs = {
|
|
|
108
108
|
},
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
|
+
'/v3/audit/work-space': {
|
|
112
|
+
get: {
|
|
113
|
+
tags: [ 'Audit' ],
|
|
114
|
+
description: 'queue wise info of audit files ',
|
|
115
|
+
operationId: 'work-space',
|
|
116
|
+
parameters: [
|
|
117
|
+
{
|
|
118
|
+
in: 'query',
|
|
119
|
+
name: 'searchValue',
|
|
120
|
+
scema: j2s( workSpaceSchema ).swagger,
|
|
121
|
+
require: false,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
in: 'query',
|
|
125
|
+
name: 'offset',
|
|
126
|
+
scema: j2s( workSpaceSchema ).swagger,
|
|
127
|
+
require: false,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
in: 'query',
|
|
131
|
+
name: 'limit',
|
|
132
|
+
scema: j2s( workSpaceSchema ).swagger,
|
|
133
|
+
require: false,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
in: 'query',
|
|
137
|
+
name: 'isExport',
|
|
138
|
+
scema: j2s( workSpaceSchema ).swagger,
|
|
139
|
+
require: false,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
responses: {
|
|
143
|
+
200: { description: 'Successful' },
|
|
144
|
+
401: { description: 'Unauthorized User' },
|
|
145
|
+
422: { description: 'Field Error' },
|
|
146
|
+
500: { description: 'Server Error' },
|
|
147
|
+
204: { description: 'Not Found' },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
|
|
111
152
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { clientMetricsSchema, getAuditImagesSchema } from '../dtos/auditMetrics.dtos.js';
|
|
2
|
+
import { clientMetricsSchema, getAuditImagesSchema, userAuditHistorySchema } from '../dtos/auditMetrics.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const auditMetricsDocs = {
|
|
5
5
|
|
|
@@ -47,4 +47,26 @@ export const auditMetricsDocs = {
|
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
|
+
'/v3/audit-metrics/user-audit-history': {
|
|
51
|
+
post: {
|
|
52
|
+
tags: [ 'Audit Metrics' ],
|
|
53
|
+
description: `Get list of user wise audit user details with date range`,
|
|
54
|
+
operationId: 'user-audit-history',
|
|
55
|
+
parameters: {},
|
|
56
|
+
requestBody: {
|
|
57
|
+
content: {
|
|
58
|
+
'application/json': {
|
|
59
|
+
schema: j2s( userAuditHistorySchema ).swagger,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
responses: {
|
|
64
|
+
200: { description: 'Successful' },
|
|
65
|
+
401: { description: 'Unauthorized User' },
|
|
66
|
+
422: { description: 'Field Error' },
|
|
67
|
+
500: { description: 'Server Error' },
|
|
68
|
+
204: { description: 'Not Found' },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
50
72
|
};
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -4,7 +4,7 @@ import joi from 'joi';
|
|
|
4
4
|
export const getFileSchema = joi.object(
|
|
5
5
|
{
|
|
6
6
|
queueName: joi.string().required(),
|
|
7
|
-
nextId: joi.string().optional(),
|
|
7
|
+
nextId: joi.string().optional().allow( '' ),
|
|
8
8
|
limit: joi.number().optional(),
|
|
9
9
|
},
|
|
10
10
|
);
|
|
@@ -15,7 +15,7 @@ export const getFileValid = {
|
|
|
15
15
|
|
|
16
16
|
export const saveDraftSchema = joi.object(
|
|
17
17
|
{
|
|
18
|
-
userCommands: joi.string().optional(),
|
|
18
|
+
userCommands: joi.string().optional().allow( '' ),
|
|
19
19
|
storeId: joi.string().required(),
|
|
20
20
|
auditId: joi.string().required(),
|
|
21
21
|
auditType: joi.string().required(),
|
|
@@ -60,15 +60,15 @@ export const saveValid = {
|
|
|
60
60
|
body: saveSchema,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
export const
|
|
63
|
+
export const workSpaceSchema = joi.object(
|
|
64
64
|
{
|
|
65
|
-
searchValue: joi.string().optional(),
|
|
65
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
66
66
|
offset: joi.string().optional(),
|
|
67
67
|
limit: joi.number().optional(),
|
|
68
|
-
|
|
68
|
+
isExport: joi.boolean().optional(),
|
|
69
69
|
},
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
export const
|
|
73
|
-
query:
|
|
72
|
+
export const workSpaceValid = {
|
|
73
|
+
query: workSpaceSchema,
|
|
74
74
|
};
|
|
@@ -15,12 +15,20 @@ export const getAuditImagesValid = {
|
|
|
15
15
|
|
|
16
16
|
export const userAuditHistorySchema = joi.object(
|
|
17
17
|
{
|
|
18
|
-
|
|
18
|
+
userId: joi.string().optional(),
|
|
19
|
+
fromDate: joi.string().required(),
|
|
19
20
|
toDate: joi.string().required(),
|
|
20
|
-
storeId: joi.string().required(),
|
|
21
|
-
fileDate: joi.string().required(),
|
|
22
21
|
fileType: joi.string().required(),
|
|
23
|
-
|
|
22
|
+
filterByStoreId: joi.array().required(),
|
|
23
|
+
filterByType: joi.array().optional(),
|
|
24
|
+
filterByStatus: joi.array().optional(),
|
|
25
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
26
|
+
limit: joi.number().optional(),
|
|
27
|
+
offset: joi.number().optional(),
|
|
28
|
+
sortColumnName: joi.string().optional(),
|
|
29
|
+
sortBy: joi.number().optional(),
|
|
30
|
+
isExport: joi.boolean().optional(),
|
|
31
|
+
|
|
24
32
|
},
|
|
25
33
|
);
|
|
26
34
|
|
|
@@ -45,7 +53,7 @@ export const clientMetricsSchema = joi.object(
|
|
|
45
53
|
{
|
|
46
54
|
fromDate: joi.string().required(),
|
|
47
55
|
toDate: joi.string().required(),
|
|
48
|
-
searchValue: joi.string().optional(),
|
|
56
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
49
57
|
filterByClient: joi.array().required(),
|
|
50
58
|
filterByStatus: joi.array().optional(),
|
|
51
59
|
sortColumnName: joi.string().optional(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { getAuditFile, getDraftedData,
|
|
5
|
-
import { getDraftedDataValid, getFileValid,
|
|
4
|
+
import { getAuditFile, getDraftedData, save, saveDraft, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { getDraftedDataValid, getFileValid, saveDraftValid, saveValid, workSpaceValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
8
8
|
|
|
@@ -10,6 +10,6 @@ auditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ),
|
|
|
10
10
|
auditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
|
|
11
11
|
auditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
|
|
12
12
|
auditRouter.post( '/save', isAllowedSessionHandler, validate( saveValid ), validateUserAudit, save );
|
|
13
|
-
auditRouter.get( '/
|
|
13
|
+
auditRouter.get( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
|
|
14
14
|
|
|
15
15
|
export default auditRouter;
|
|
@@ -7,3 +7,7 @@ export function updateOneStoreAudit( query, record ) {
|
|
|
7
7
|
export function createStoreAudit( record ) {
|
|
8
8
|
return storeAuditModel.create( record );
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
export function aggregateStoreAudit( query ) {
|
|
12
|
+
return storeAuditModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
13
|
+
}
|