tango-app-api-audit 3.3.0-alpha.13 → 3.3.0-alpha.14

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-alpha.13",
3
+ "version": "3.3.0-alpha.14",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -738,21 +738,24 @@ export const mapFunction = async ( chunk, filter ) => {
738
738
 
739
739
  export async function workSpace( req, res ) {
740
740
  try {
741
- const inputData = req.query;
741
+ const inputData = req.body;
742
742
  const limit = inputData.limit || 10;
743
743
  const offset = inputData.offset ?
744
744
  ( inputData.offset - 1 ) * limit :
745
745
  0;
746
746
  const dateRange = await getUTC( new Date(), new Date() );
747
-
747
+ const filter =[
748
+ { status: { $in: [ 'active', 'hold' ] } },
749
+ { 'auditConfigs.audit': { $eq: true } },
750
+ ];
751
+ if ( inputData?.clientId?.length > 0 ) {
752
+ filter.push( { clientId: { $in: inputData.clientId } } );
753
+ }
748
754
  const temp = [];
749
755
  const clientQuery = [
750
756
  {
751
757
  $match: {
752
- $and: [
753
- { status: { $in: [ 'active', 'hold' ] } },
754
- { 'auditConfigs.audit': { $eq: true } },
755
- ],
758
+ $and: filter,
756
759
  },
757
760
  },
758
761
  {
@@ -777,7 +780,7 @@ export async function workSpace( req, res ) {
777
780
  if ( inputData.sortColumnName ) {
778
781
  const sortBy = inputData.sortBy || -1;
779
782
  const sortColumn = inputData.sortColumnName;
780
- query.push( {
783
+ clientQuery.push( {
781
784
  $sort: { [sortColumn]: sortBy },
782
785
  },
783
786
  );
@@ -1475,7 +1478,9 @@ export async function userAuditHistory( req, res ) {
1475
1478
  auditStatus: { $in: inputData.filterByStatus },
1476
1479
  } );
1477
1480
  }
1478
-
1481
+ if ( inputData?.clientId?.length > 0 ) {
1482
+ filter.push( { clientId: { $in: inputData.clientId } } );
1483
+ }
1479
1484
  const query = [
1480
1485
  {
1481
1486
  $match: {
@@ -1639,18 +1644,18 @@ export async function userAuditHistory( req, res ) {
1639
1644
  chunk.forEach( ( element ) => {
1640
1645
  exportData.push( {
1641
1646
 
1642
- 'Client ID': element.clientId,
1643
- 'Client Name': element.clientName,
1647
+ 'Brand ID': element.clientId,
1648
+ 'Brand Name': element.clientName,
1644
1649
  'Store ID': element.storeId,
1645
1650
  'Store Name': element.storeName,
1646
1651
  'Zone Name': element.zoneName,
1647
1652
  'Audit Type': element.auditType,
1648
1653
  'Module Type': element.moduleType,
1649
1654
  'Before Count': element.beforeCount,
1650
- 'After Count': element.afterCount,
1651
- 'Accuracy': element.accuracy,
1655
+ 'After Count': element.afterCount || '',
1656
+ 'Accuracy': element.accuracy || '',
1652
1657
  'Start Time': element.startTime,
1653
- 'End Time': element.endTime,
1658
+ 'End Time': element.endTime || '',
1654
1659
  'Time Spent': element.timeSpent,
1655
1660
  'Audit Status': element.auditStatus,
1656
1661
  'CreatedAt': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
@@ -1661,8 +1666,8 @@ export async function userAuditHistory( req, res ) {
1661
1666
  } );
1662
1667
  const mappedArrays = await Promise.all( promises );
1663
1668
  mappedArrays.flat();
1664
-
1665
- await download( mappedArrays, res );
1669
+ logger.info( { mappedArrays: mappedArrays[0] } );
1670
+ await download( mappedArrays[0], res );
1666
1671
  return;
1667
1672
  }
1668
1673
 
@@ -223,54 +223,17 @@ export const auditDocs = {
223
223
  },
224
224
  },
225
225
  '/v3/audit/work-space': {
226
- get: {
226
+ post: {
227
227
  tags: [ 'Audit Mapping' ],
228
228
  description: 'queue wise info of audit files ',
229
229
  operationId: 'work-space',
230
- parameters: [
231
- {
232
- in: 'query',
233
- name: 'moduleType',
234
- scema: j2s( workSpaceSchema ).swagger,
235
- require: true,
236
- },
237
- {
238
- in: 'query',
239
- name: 'searchValue',
240
- scema: j2s( workSpaceSchema ).swagger,
241
- require: false,
242
- },
243
- {
244
- in: 'query',
245
- name: 'offset',
246
- scema: j2s( workSpaceSchema ).swagger,
247
- require: false,
248
- },
249
- {
250
- in: 'query',
251
- name: 'limit',
252
- scema: j2s( workSpaceSchema ).swagger,
253
- require: false,
254
- },
255
- {
256
- in: 'query',
257
- name: 'isExport',
258
- scema: j2s( workSpaceSchema ).swagger,
259
- require: false,
260
- },
261
- {
262
- in: 'query',
263
- name: 'sortColumnName',
264
- scema: j2s( workSpaceSchema ).swagger,
265
- require: false,
266
- },
267
- {
268
- in: 'query',
269
- name: 'sortBy',
270
- scema: j2s( workSpaceSchema ).swagger,
271
- require: false,
230
+ requestBody: {
231
+ content: {
232
+ 'application/json': {
233
+ schema: j2s( workSpaceSchema ).swagger,
234
+ },
272
235
  },
273
- ],
236
+ },
274
237
  responses: {
275
238
  200: { description: 'Successful' },
276
239
  401: { description: 'Unauthorized User' },
@@ -125,6 +125,7 @@ export const workSpaceSchema = joi.object(
125
125
  {
126
126
  searchValue: joi.string().optional().allow( '' ),
127
127
  moduleType: joi.string().required(),
128
+ clientId: joi.array().optional(),
128
129
  offset: joi.number().optional(),
129
130
  limit: joi.number().optional(),
130
131
  isExport: joi.boolean().optional(),
@@ -134,7 +135,7 @@ export const workSpaceSchema = joi.object(
134
135
  );
135
136
 
136
137
  export const workSpaceValid = {
137
- query: workSpaceSchema,
138
+ body: workSpaceSchema,
138
139
  };
139
140
 
140
141
  /* < -- *** Audit Metrics *** --> */
@@ -145,6 +146,7 @@ export const userAuditHistorySchema = joi.object(
145
146
  fromDate: joi.string().required(),
146
147
  toDate: joi.string().required(),
147
148
  dateType: joi.string().required(),
149
+ clientId: joi.array().optional(),
148
150
  filterByStoreId: joi.array().required(),
149
151
  filterByModuleType: joi.array().optional(),
150
152
  filterByAuditType: joi.array().optional(),
@@ -17,7 +17,7 @@ auditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ),
17
17
  auditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
18
18
  auditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
19
19
  auditRouter.post( '/save', isAllowedSessionHandler, validate( saveValid ), validateUserAudit, save );
20
- auditRouter.get( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
20
+ auditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
21
21
 
22
22
  // Audit Metrics
23
23
  auditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );