tango-app-api-audit 3.3.0-beta.2 → 3.3.0
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/README.md +28 -28
- package/package.json +40 -40
- package/src/controllers/audit.controllers.js +94 -47
- package/src/service/auditStoreData.service.js +10 -10
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# README #
|
|
2
|
-
|
|
3
|
-
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
-
|
|
5
|
-
### What is this repository for? ###
|
|
6
|
-
|
|
7
|
-
* Quick summary
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
-
|
|
11
|
-
### How do I get set up? ###
|
|
12
|
-
|
|
13
|
-
* Summary of set up
|
|
14
|
-
* Configuration
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
19
|
-
|
|
20
|
-
### Contribution guidelines ###
|
|
21
|
-
|
|
22
|
-
* Writing tests
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
25
|
-
|
|
26
|
-
### Who do I talk to? ###
|
|
27
|
-
|
|
28
|
-
* Repo owner or admin
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
29
|
* Other community or team contact
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.3.0
|
|
4
|
-
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18.10.0"
|
|
12
|
-
},
|
|
13
|
-
"author": "praveenraj",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"adm-zip": "^0.5.15",
|
|
17
|
-
"aws-sdk": "^2.1643.0",
|
|
18
|
-
"dayjs": "^1.11.11",
|
|
19
|
-
"dotenv": "^16.4.5",
|
|
20
|
-
"express": "^4.19.2",
|
|
21
|
-
"handlebars": "^4.7.8",
|
|
22
|
-
"joi-to-swagger": "^6.2.0",
|
|
23
|
-
"lodash": "^4.17.21",
|
|
24
|
-
"mongodb": "^6.7.0",
|
|
25
|
-
"nodemon": "^3.1.3",
|
|
26
|
-
"swagger-ui-express": "^5.0.1",
|
|
27
|
-
"tango-api-schema": "^2.0.159",
|
|
28
|
-
"tango-app-api-middleware": "^3.1.32",
|
|
29
|
-
"winston": "^3.13.0",
|
|
30
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"eslint": "^8.57.0",
|
|
34
|
-
"eslint-config-google": "^0.14.0",
|
|
35
|
-
"eslint-config-semistandard": "^17.0.0",
|
|
36
|
-
"eslint-config-standard": "^17.1.0",
|
|
37
|
-
"eslint-plugin-import": "^2.29.1",
|
|
38
|
-
"eslint-plugin-promise": "^6.2.0"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tango-app-api-audit",
|
|
3
|
+
"version": "3.3.0",
|
|
4
|
+
"description": "audit & audit metrics apis",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.10.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "praveenraj",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"adm-zip": "^0.5.15",
|
|
17
|
+
"aws-sdk": "^2.1643.0",
|
|
18
|
+
"dayjs": "^1.11.11",
|
|
19
|
+
"dotenv": "^16.4.5",
|
|
20
|
+
"express": "^4.19.2",
|
|
21
|
+
"handlebars": "^4.7.8",
|
|
22
|
+
"joi-to-swagger": "^6.2.0",
|
|
23
|
+
"lodash": "^4.17.21",
|
|
24
|
+
"mongodb": "^6.7.0",
|
|
25
|
+
"nodemon": "^3.1.3",
|
|
26
|
+
"swagger-ui-express": "^5.0.1",
|
|
27
|
+
"tango-api-schema": "^2.0.159",
|
|
28
|
+
"tango-app-api-middleware": "^3.1.32",
|
|
29
|
+
"winston": "^3.13.0",
|
|
30
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"eslint": "^8.57.0",
|
|
34
|
+
"eslint-config-google": "^0.14.0",
|
|
35
|
+
"eslint-config-semistandard": "^17.0.0",
|
|
36
|
+
"eslint-config-standard": "^17.1.0",
|
|
37
|
+
"eslint-plugin-import": "^2.29.1",
|
|
38
|
+
"eslint-plugin-promise": "^6.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1647,14 +1647,14 @@ export async function userAuditHistory( req, res ) {
|
|
|
1647
1647
|
const exportData = [];
|
|
1648
1648
|
chunk.forEach( ( element ) => {
|
|
1649
1649
|
exportData.push( {
|
|
1650
|
-
|
|
1650
|
+
'File Date': element.fileDate,
|
|
1651
1651
|
'Brand ID': element.clientId,
|
|
1652
1652
|
'Brand Name': element.clientName,
|
|
1653
1653
|
'Store ID': element.storeId,
|
|
1654
1654
|
'Store Name': element.storeName,
|
|
1655
|
-
'Zone Name': element.zoneName,
|
|
1655
|
+
'Zone Name': element.moduleType == 'zone'? element.zoneName : '',
|
|
1656
1656
|
'Audit Type': element.auditType,
|
|
1657
|
-
'
|
|
1657
|
+
'Product Type': element.moduleType,
|
|
1658
1658
|
'Before Count': element.beforeCount,
|
|
1659
1659
|
'After Count': element.afterCount || '',
|
|
1660
1660
|
'Accuracy': element.accuracy || '',
|
|
@@ -1662,7 +1662,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1662
1662
|
'End Time': element.endTime || '',
|
|
1663
1663
|
'Time Spent': element.timeSpent,
|
|
1664
1664
|
'Audit Status': element.auditStatus,
|
|
1665
|
-
'
|
|
1665
|
+
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1666
1666
|
|
|
1667
1667
|
} );
|
|
1668
1668
|
} );
|
|
@@ -1788,7 +1788,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1788
1788
|
completedStores: 1,
|
|
1789
1789
|
inprogressStores: 1,
|
|
1790
1790
|
notAssignedStores: 1,
|
|
1791
|
-
fileCount:
|
|
1791
|
+
fileCount: { $ifNull: [ '$fileCount', 0 ] },
|
|
1792
1792
|
completionPercentage: { $ifNull: [
|
|
1793
1793
|
{
|
|
1794
1794
|
$round: [ {
|
|
@@ -1828,8 +1828,8 @@ export async function clientMetrics( req, res ) {
|
|
|
1828
1828
|
// notAssignedStores: '$storeAudit.notAssignedStores',
|
|
1829
1829
|
inprogressStoresCount: '$storeAudit.inprogressStores',
|
|
1830
1830
|
// fileCount: '$storeAudit.fileCount',
|
|
1831
|
-
notAssignedCount:
|
|
1832
|
-
clientStatus: { $cond: [ { $eq: [ '$storeAudit.fileCount', 0 ] }, 'not-taken', { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }
|
|
1831
|
+
notAssignedCount: { $subtract: [ '$totalFilesCount', { $subtract: [ { $ifNull: [ '$storeAudit.fileCount', 0 ] }, { $ifNull: [ '$storeAudit.notAssignedStores', 0 ] } ] } ] },
|
|
1832
|
+
clientStatus: { $cond: [ { $eq: [ { $ifNull: [ '$storeAudit.fileCount', 0 ] }, 0 ] }, 'not-taken', { $cond: [ { $gte: [ '$storeAudit.completedStores', '$totalFilesCount' ] }, 'completed', 'pending' ] } ] }, // { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }
|
|
1833
1833
|
completedStores: '$storeAudit.completedStores',
|
|
1834
1834
|
completionPercentage: '$storeAudit.completionPercentage',
|
|
1835
1835
|
|
|
@@ -1885,7 +1885,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1885
1885
|
'File Date': '$fileDate',
|
|
1886
1886
|
'Client Name': '$clientName',
|
|
1887
1887
|
'Client Id': '$clientId',
|
|
1888
|
-
'
|
|
1888
|
+
'Product Type': '$moduleType',
|
|
1889
1889
|
'Completed Percentage': '$completionPercentage',
|
|
1890
1890
|
'Installed Stores': '$installedStore',
|
|
1891
1891
|
'Audit Stores': '$totalFilesCount',
|
|
@@ -2127,6 +2127,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2127
2127
|
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2128
2128
|
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2129
2129
|
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2130
|
+
{ zoneName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2130
2131
|
],
|
|
2131
2132
|
},
|
|
2132
2133
|
} );
|
|
@@ -2159,19 +2160,36 @@ export async function storeMetrics( req, res ) {
|
|
|
2159
2160
|
if ( inputData.isExport ) {
|
|
2160
2161
|
const exportdata = [];
|
|
2161
2162
|
result.forEach( ( element ) => {
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2163
|
+
if ( element.moduleType == 'zone' ) {
|
|
2164
|
+
exportdata.push( {
|
|
2165
|
+
'File Date': element.fileDate,
|
|
2166
|
+
'Store ID': element.storeId,
|
|
2167
|
+
'Store Name': element.storeName,
|
|
2168
|
+
'Client Id': element.clientId,
|
|
2169
|
+
'Client Name': element.clientName,
|
|
2170
|
+
'Zone Name': element.zoneName,
|
|
2171
|
+
'User Name': element.userName,
|
|
2172
|
+
'User Email': element.userEmail,
|
|
2173
|
+
'Audit Type': element.auditType,
|
|
2174
|
+
'Accuracy': element.accuracy,
|
|
2175
|
+
'Time Spent': element.timeSpent,
|
|
2176
|
+
'Status': element.status,
|
|
2177
|
+
} );
|
|
2178
|
+
} else {
|
|
2179
|
+
exportdata.push( {
|
|
2180
|
+
'File Date': element.fileDate,
|
|
2181
|
+
'Store ID': element.storeId,
|
|
2182
|
+
'Store Name': element.storeName,
|
|
2183
|
+
'Client Id': element.clientId,
|
|
2184
|
+
'Client Name': element.clientName,
|
|
2185
|
+
'User Name': element.userName,
|
|
2186
|
+
'User Email': element.userEmail,
|
|
2187
|
+
'Audit Type': element.auditType,
|
|
2188
|
+
'Accuracy': element.accuracy,
|
|
2189
|
+
'Time Spent': element.timeSpent,
|
|
2190
|
+
'Status': element.status,
|
|
2191
|
+
} );
|
|
2192
|
+
}
|
|
2175
2193
|
} );
|
|
2176
2194
|
await download( exportdata, res );
|
|
2177
2195
|
return;
|
|
@@ -2597,18 +2615,32 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2597
2615
|
if ( inputData.isExport ) {
|
|
2598
2616
|
const exportdata = [];
|
|
2599
2617
|
result.forEach( ( element ) => {
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2618
|
+
if ( element.moduleType == 'zone' ) {
|
|
2619
|
+
exportdata.push( {
|
|
2620
|
+
'Store ID': element.storeId,
|
|
2621
|
+
'zoneName': element.zoneName,
|
|
2622
|
+
'File Date': element.fileDate,
|
|
2623
|
+
'Product Type': element.moduleType,
|
|
2624
|
+
'Audit Type': element.auditType,
|
|
2625
|
+
'Before Count': element.beforeCount,
|
|
2626
|
+
'Start Time': element.startTime,
|
|
2627
|
+
'User Name': element.userName,
|
|
2628
|
+
'User Email': element.userEmail,
|
|
2629
|
+
'Status': element.auditStatus,
|
|
2630
|
+
} );
|
|
2631
|
+
} else {
|
|
2632
|
+
exportdata.push( {
|
|
2633
|
+
'Store ID': element.storeId,
|
|
2634
|
+
'File Date': element.fileDate,
|
|
2635
|
+
'Product Type': element.moduleType,
|
|
2636
|
+
'Audit Type': element.auditType,
|
|
2637
|
+
'Before Count': element.beforeCount,
|
|
2638
|
+
'Start Time': element.startTime,
|
|
2639
|
+
'User Name': element.userName,
|
|
2640
|
+
'User Email': element.userEmail,
|
|
2641
|
+
'Status': element.auditStatus,
|
|
2642
|
+
} );
|
|
2643
|
+
}
|
|
2612
2644
|
} );
|
|
2613
2645
|
await download( exportdata, res );
|
|
2614
2646
|
return;
|
|
@@ -2883,7 +2915,7 @@ export async function reTrigger( req, res ) {
|
|
|
2883
2915
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
2884
2916
|
}
|
|
2885
2917
|
|
|
2886
|
-
return res.sendSuccess( { result: 'The File has been Re
|
|
2918
|
+
return res.sendSuccess( { result: 'The File has been Re-Triggered Succesfully' } );
|
|
2887
2919
|
} catch ( error ) {
|
|
2888
2920
|
const err = error.message;
|
|
2889
2921
|
logger.error( { error: error, message: req.body, function: 'reTrigger' } );
|
|
@@ -3239,19 +3271,34 @@ export async function overviewTable( req, res ) {
|
|
|
3239
3271
|
if ( inputData.isExport ) {
|
|
3240
3272
|
const exportdata = [];
|
|
3241
3273
|
result.forEach( ( element ) => {
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3274
|
+
if ( element.moduleType == 'zone' ) {
|
|
3275
|
+
exportdata.push( {
|
|
3276
|
+
'Store ID': element.storeId,
|
|
3277
|
+
'Brand ID': element.clientId,
|
|
3278
|
+
'Zone Name': element.zoneName,
|
|
3279
|
+
'File Date': element.fileDate,
|
|
3280
|
+
'Product Type': element.moduleType,
|
|
3281
|
+
'Audit Type': element.auditType,
|
|
3282
|
+
'Before Count': element.beforeCount,
|
|
3283
|
+
'After Count': element.afterCount,
|
|
3284
|
+
// 'User Name': element.userName,
|
|
3285
|
+
// 'User Email': element.userEmail,
|
|
3286
|
+
'Status': element.status,
|
|
3287
|
+
} );
|
|
3288
|
+
} else {
|
|
3289
|
+
exportdata.push( {
|
|
3290
|
+
'Store ID': element.storeId,
|
|
3291
|
+
'Brand ID': element.clientId,
|
|
3292
|
+
'File Date': element.fileDate,
|
|
3293
|
+
'Product Type': element.moduleType,
|
|
3294
|
+
'Audit Type': element.auditType,
|
|
3295
|
+
'Before Count': element.beforeCount,
|
|
3296
|
+
'After Count': element.afterCount,
|
|
3297
|
+
// 'User Name': element.userName,
|
|
3298
|
+
// 'User Email': element.userEmail,
|
|
3299
|
+
'Status': element.status,
|
|
3300
|
+
} );
|
|
3301
|
+
}
|
|
3255
3302
|
} );
|
|
3256
3303
|
await download( exportdata, res );
|
|
3257
3304
|
return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import auditStoreDataModel from 'tango-api-schema/schema/auditStoreData.model.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function aggregateAuditStoreData( query ) {
|
|
5
|
-
return auditStoreDataModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function findOneStoreData( query, fields, sort ) {
|
|
9
|
-
return auditStoreDataModel.findOne( query, fields ).sort( sort );
|
|
10
|
-
}
|
|
1
|
+
import auditStoreDataModel from 'tango-api-schema/schema/auditStoreData.model.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function aggregateAuditStoreData( query ) {
|
|
5
|
+
return auditStoreDataModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function findOneStoreData( query, fields, sort ) {
|
|
9
|
+
return auditStoreDataModel.findOne( query, fields ).sort( sort );
|
|
10
|
+
}
|