tango-app-api-audit 1.0.39 → 1.0.40
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
|
@@ -22,7 +22,6 @@ export async function userAuditHistory( req, res ) {
|
|
|
22
22
|
let filter = [
|
|
23
23
|
|
|
24
24
|
{ userId: { $eq: userId } },
|
|
25
|
-
{ moduleType: 'traffic' },
|
|
26
25
|
|
|
27
26
|
];
|
|
28
27
|
if ( inputData.fileType == 'fileDate' ) {
|
|
@@ -37,6 +36,12 @@ export async function userAuditHistory( req, res ) {
|
|
|
37
36
|
);
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
if ( inputData.auditType?.length > 0 ) {
|
|
40
|
+
filter.push( {
|
|
41
|
+
moduleType: { $in: inputData.auditType },
|
|
42
|
+
} );
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
if ( inputData.filterByStoreId?.length > 0 ) {
|
|
41
46
|
filter.push( {
|
|
42
47
|
storeId: { $in: inputData.filterByStoreId },
|
|
@@ -57,17 +62,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
57
62
|
},
|
|
58
63
|
];
|
|
59
64
|
|
|
60
|
-
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
61
|
-
query.push( {
|
|
62
|
-
$match: {
|
|
63
|
-
$or: [
|
|
64
|
-
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
65
|
-
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
66
|
-
],
|
|
67
65
|
|
|
68
|
-
},
|
|
69
|
-
} );
|
|
70
|
-
}
|
|
71
66
|
if ( inputData.sortColumnName ) {
|
|
72
67
|
const sortBy = inputData.sortBy || -1;
|
|
73
68
|
query.push( {
|
|
@@ -110,6 +105,8 @@ export async function userAuditHistory( req, res ) {
|
|
|
110
105
|
userId: 1,
|
|
111
106
|
storeName: '$store.storeName',
|
|
112
107
|
auditType: 1,
|
|
108
|
+
zoneName: 1,
|
|
109
|
+
moduleType: 1,
|
|
113
110
|
beforeCount: 1,
|
|
114
111
|
afterCount: 1,
|
|
115
112
|
accuracy: { $round: [
|
|
@@ -128,6 +125,21 @@ export async function userAuditHistory( req, res ) {
|
|
|
128
125
|
},
|
|
129
126
|
} );
|
|
130
127
|
|
|
128
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
129
|
+
query.push( {
|
|
130
|
+
$match: {
|
|
131
|
+
$or: [
|
|
132
|
+
{ zoneName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
133
|
+
{ storeId: { $regex: inputData.storeId, $options: 'i' } },
|
|
134
|
+
{ storeName: { $regex: inputData.storeName, $options: 'i' } },
|
|
135
|
+
{ moduleType: { $regex: inputData.moduleType, $options: 'i' } },
|
|
136
|
+
{ auditStatus: { $regex: inputData.auditStatus, $options: 'i' } },
|
|
137
|
+
],
|
|
138
|
+
|
|
139
|
+
},
|
|
140
|
+
} );
|
|
141
|
+
}
|
|
142
|
+
|
|
131
143
|
const count = await aggregateUserAudit( query );
|
|
132
144
|
if ( count.length == 0 ) {
|
|
133
145
|
return res.sendError( 'No Data Found', 204 );
|
|
@@ -139,17 +151,19 @@ export async function userAuditHistory( req, res ) {
|
|
|
139
151
|
const exportData = [];
|
|
140
152
|
chunk.forEach( ( element ) => {
|
|
141
153
|
exportData.push( {
|
|
142
|
-
'
|
|
143
|
-
'
|
|
144
|
-
'
|
|
145
|
-
'
|
|
146
|
-
'
|
|
147
|
-
'
|
|
148
|
-
'
|
|
149
|
-
'
|
|
150
|
-
'
|
|
151
|
-
'
|
|
152
|
-
'
|
|
154
|
+
'Store Id': element.storeId,
|
|
155
|
+
'Store Name': element.storeName,
|
|
156
|
+
'Type': element.auditType,
|
|
157
|
+
'Before Count': element.beforeCount,
|
|
158
|
+
'After Count': element.afterCount,
|
|
159
|
+
'Accuracy': element.accuracy,
|
|
160
|
+
'Zone Name': element.zoneName,
|
|
161
|
+
'Audit Type': element.moduleType,
|
|
162
|
+
'Start Time': element.startTime,
|
|
163
|
+
'End Time': element.endTime,
|
|
164
|
+
'Time Spent': element.timeSpent,
|
|
165
|
+
'Audit Status': element.auditStatus,
|
|
166
|
+
'CreatedAt': element.createdAt,
|
|
153
167
|
|
|
154
168
|
} );
|
|
155
169
|
} );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema,
|
|
2
|
+
import { getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, workSpaceSchema } from '../dtos/zoneAudit.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const zoneAuditDocs = {
|
|
5
5
|
'/v3/zone-audit/get-file': {
|
|
@@ -155,27 +155,4 @@ export const zoneAuditDocs = {
|
|
|
155
155
|
},
|
|
156
156
|
},
|
|
157
157
|
|
|
158
|
-
// metrics
|
|
159
|
-
'/v3/zone-audit/metrics/user-zone-audit-history': {
|
|
160
|
-
post: {
|
|
161
|
-
tags: [ 'Zone Audit Metrics' ],
|
|
162
|
-
description: `get zone audit work history of a user`,
|
|
163
|
-
operationId: '/metrics/user-zone-audit-history',
|
|
164
|
-
parameters: {},
|
|
165
|
-
requestBody: {
|
|
166
|
-
content: {
|
|
167
|
-
'application/json': {
|
|
168
|
-
schema: j2s( userZoneAuditHistorySchema ).swagger,
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
responses: {
|
|
173
|
-
200: { description: 'The Audited file has been submited successfully ' },
|
|
174
|
-
401: { description: 'Unauthorized User' },
|
|
175
|
-
422: { description: 'Field Error' },
|
|
176
|
-
500: { description: 'Server Error' },
|
|
177
|
-
204: { description: 'Not Found' },
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
158
|
};
|
|
@@ -44,6 +44,7 @@ export const storeMetricsSchema = joi.object(
|
|
|
44
44
|
filterByClientId: joi.array().required(),
|
|
45
45
|
filterByStoreId: joi.array().optional(),
|
|
46
46
|
filterByStatus: joi.array().optional(),
|
|
47
|
+
filterByAuditType: joi.array().optional(),
|
|
47
48
|
sortColumnName: joi.string().optional(),
|
|
48
49
|
sortBy: joi.number().optional(),
|
|
49
50
|
limit: joi.number().optional(),
|
|
@@ -87,26 +87,3 @@ export const workSpaceValid = {
|
|
|
87
87
|
query: workSpaceSchema,
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
export const userZoneAuditHistorySchema = joi.object(
|
|
91
|
-
{
|
|
92
|
-
userId: joi.string().optional(),
|
|
93
|
-
fromDate: joi.string().required(),
|
|
94
|
-
toDate: joi.string().required(),
|
|
95
|
-
fileType: joi.string().required(),
|
|
96
|
-
filterByStoreId: joi.array().required(),
|
|
97
|
-
filterByType: joi.array().optional(),
|
|
98
|
-
filterByAuditType: joi.array().optional(),
|
|
99
|
-
filterByStatus: joi.array().optional(),
|
|
100
|
-
searchValue: joi.string().optional().allow( '' ),
|
|
101
|
-
limit: joi.number().optional(),
|
|
102
|
-
offset: joi.number().optional(),
|
|
103
|
-
sortColumnName: joi.string().optional(),
|
|
104
|
-
sortBy: joi.number().optional(),
|
|
105
|
-
isExport: joi.boolean().optional(),
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
export const userZoneAuditHistoryValid = {
|
|
111
|
-
body: userZoneAuditHistorySchema,
|
|
112
|
-
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { getDraftedDataValid, getFileValid, saveDraftValid, saveValid,
|
|
2
|
+
import { getDraftedDataValid, getFileValid, saveDraftValid, saveValid, workSpaceValid } from '../dtos/zoneAudit.dtos.js';
|
|
3
3
|
import { isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
4
4
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
5
|
-
import { getDraftedData, getZoneAuditFile, save, saveDraft,
|
|
5
|
+
import { getDraftedData, getZoneAuditFile, save, saveDraft, workSpace } from '../controllers/zoneAudit.controller.js';
|
|
6
6
|
|
|
7
7
|
export const zoneAuditRouter=Router();
|
|
8
8
|
|
|
@@ -12,6 +12,3 @@ zoneAuditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraf
|
|
|
12
12
|
zoneAuditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
|
|
13
13
|
zoneAuditRouter.post( '/save', isAllowedSessionHandler, validate( saveValid ), validateUserAudit, save );
|
|
14
14
|
zoneAuditRouter.get( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
|
|
15
|
-
|
|
16
|
-
// metrics
|
|
17
|
-
zoneAuditRouter.post( '/metrics/user-zone-audit-history', isAllowedSessionHandler, validate( userZoneAuditHistoryValid ), userZoneAuditHistory );
|