tango-app-api-audit 1.0.16 → 1.0.18
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 +1 -1
- package/src/controllers/auditMetrics.controllers.js +169 -1
- package/src/controllers/store.controllers.js +9 -44
- package/src/controllers/user.controllers.js +41 -0
- package/src/docs/auditMetrics.docs.js +23 -1
- package/src/docs/store.docs.js +11 -29
- package/src/docs/user.docs.js +33 -0
- package/src/dtos/audit.dtos.js +0 -1
- package/src/dtos/auditMetrics.dtos.js +20 -0
- package/src/dtos/store.dtos.js +2 -3
- package/src/dtos/user.dtos.js +14 -0
- package/src/routes/auditMetrics.routes.js +3 -2
- package/src/routes/store.routes.js +1 -1
- package/src/routes/user.routes.js +9 -0
- package/src/service/store.service.js +4 -0
- package/src/service/user.service.js +4 -0
package/package.json
CHANGED
|
@@ -324,7 +324,6 @@ export async function storeMetrics( req, res ) {
|
|
|
324
324
|
|
|
325
325
|
export async function clientMetrics( req, res ) {
|
|
326
326
|
try {
|
|
327
|
-
// const sqs = JSON.parse( process.env.SQS );
|
|
328
327
|
const inputData = req.body;
|
|
329
328
|
const limit = inputData.limit || 10;
|
|
330
329
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
@@ -495,3 +494,172 @@ export async function clientMetrics( req, res ) {
|
|
|
495
494
|
return res.sendError( err, 500 );
|
|
496
495
|
}
|
|
497
496
|
}
|
|
497
|
+
|
|
498
|
+
export async function userMetrics( req, res ) {
|
|
499
|
+
try {
|
|
500
|
+
const inputData = req.body;
|
|
501
|
+
const limit = inputData.limit || 10;
|
|
502
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
503
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
504
|
+
let filter = [];
|
|
505
|
+
if ( inputData.fileType == 'auditedDate' ) {
|
|
506
|
+
filter.push(
|
|
507
|
+
{ createdAt: { $gte: dateRange.start } },
|
|
508
|
+
{ updatedAt: { $lte: dateRange.end } },
|
|
509
|
+
|
|
510
|
+
);
|
|
511
|
+
} else {
|
|
512
|
+
filter.push(
|
|
513
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
514
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
515
|
+
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
if ( inputData?.filterByStatus?.length> 0 ) {
|
|
519
|
+
filter.push(
|
|
520
|
+
{ auditStatus: { $in: inputData.filterByStatus } },
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
if ( inputData?.filterByuser?.length> 0 ) {
|
|
524
|
+
filter.push(
|
|
525
|
+
{ userId: { $in: inputData.filterByuser } },
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const query = [
|
|
530
|
+
{
|
|
531
|
+
$match: {
|
|
532
|
+
$and: filter,
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
$group: {
|
|
537
|
+
_id: { userId: '$userId', fileDate: '$fileDate' },
|
|
538
|
+
userId: { $first: '$userId' },
|
|
539
|
+
fileDate: { $first: '$fileDate' },
|
|
540
|
+
totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $sum: 1 } ] },
|
|
541
|
+
beforeCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $sum: { $ifNull: [ '$beforeCount', 0 ] } } ] },
|
|
542
|
+
afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $sum: { $ifNull: [ '$afterCount', 0 ] } } ] },
|
|
543
|
+
checkIntime: { $first: '$createdAt' },
|
|
544
|
+
checkOutTime: { $last: '$createdAt' },
|
|
545
|
+
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
$project: {
|
|
550
|
+
_id: 0,
|
|
551
|
+
userName: '$userId',
|
|
552
|
+
userId: 1,
|
|
553
|
+
fileDate: 1,
|
|
554
|
+
totalCompletedFiles: 1,
|
|
555
|
+
beforeCount: 1,
|
|
556
|
+
afterCount: 1,
|
|
557
|
+
mappingPerc: { $round: [
|
|
558
|
+
{ $multiply: [
|
|
559
|
+
{ $divide: [ '$afterCount', 'beforeCount' ] }, 100,
|
|
560
|
+
] }, 2,
|
|
561
|
+
] },
|
|
562
|
+
checkIntime: 1,
|
|
563
|
+
checkOutTime: 1,
|
|
564
|
+
differenceInSeconds: {
|
|
565
|
+
$divide: [ { $subtract: [ '$checkIntime', '$checkoutTime' ] }, 1000 ],
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
$project: {
|
|
571
|
+
userName: 1,
|
|
572
|
+
userId: 1,
|
|
573
|
+
fileDate: 1,
|
|
574
|
+
totalCompletedFiles: 1,
|
|
575
|
+
beforeCount: 1,
|
|
576
|
+
afterCount: 1,
|
|
577
|
+
checkIntime: 1,
|
|
578
|
+
checkOutTime: 1,
|
|
579
|
+
mappingPerc: 1,
|
|
580
|
+
hours: { $floor: { $divide: [ '$differenceInSeconds', 3600 ] } },
|
|
581
|
+
minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
|
|
582
|
+
seconds: { $mod: [ '$differenceInSeconds', 60 ] },
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
$project: {
|
|
587
|
+
event: 1,
|
|
588
|
+
userName: 1,
|
|
589
|
+
userId: 1,
|
|
590
|
+
fileDate: 1,
|
|
591
|
+
totalCompletedFiles: 1,
|
|
592
|
+
beforeCount: 1,
|
|
593
|
+
afterCount: 1,
|
|
594
|
+
checkIntime: 1,
|
|
595
|
+
checkOutTime: 1,
|
|
596
|
+
workingHours: {
|
|
597
|
+
$concat: [
|
|
598
|
+
{ $toString: '$hours' }, ':',
|
|
599
|
+
{ $substr: [ { $toString: { $add: [ { $cond: [ { $lt: [ '$minutes', 10 ] }, '0', '' ] }, '$minutes' ] } }, 0, 2 ] }, ':',
|
|
600
|
+
{ $substr: [ { $toString: { $add: [ { $cond: [ { $lt: [ '$seconds', 10 ] }, '0', '' ] }, '$seconds' ] } }, 0, 2 ] },
|
|
601
|
+
],
|
|
602
|
+
},
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
];
|
|
606
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
607
|
+
query.push( {
|
|
608
|
+
$match: {
|
|
609
|
+
$or: [
|
|
610
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
611
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
612
|
+
],
|
|
613
|
+
|
|
614
|
+
},
|
|
615
|
+
} );
|
|
616
|
+
}
|
|
617
|
+
if ( inputData.sortColumnName ) {
|
|
618
|
+
const sortBy = inputData.sortBy || -1;
|
|
619
|
+
query.push( {
|
|
620
|
+
$sort: { [inputData.sortColumName]: sortBy },
|
|
621
|
+
},
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
const count = await aggregateUserAudit( query );
|
|
626
|
+
if ( count.length == 0 ) {
|
|
627
|
+
return res.sendError( 'No Data Found', 204 );
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
query.push(
|
|
631
|
+
{ $skip: offset },
|
|
632
|
+
{ $limit: limit },
|
|
633
|
+
);
|
|
634
|
+
if ( inputData.isExport ) {
|
|
635
|
+
query.push(
|
|
636
|
+
{
|
|
637
|
+
$project: {
|
|
638
|
+
'_id': 0,
|
|
639
|
+
'File Date': '$fileDate',
|
|
640
|
+
'zuser Name': '$userName',
|
|
641
|
+
'User Id': '$userId',
|
|
642
|
+
'Total Completed Files Count': '$totalCompletedFiles',
|
|
643
|
+
'Total efore Count': '$beforeCount',
|
|
644
|
+
'Total After Count': '$afterCount',
|
|
645
|
+
'check Intime': '$checkIntime',
|
|
646
|
+
'check OutTime': '$checkOutTime',
|
|
647
|
+
'working Hours': '$workingHours',
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
const result = await aggregateUserAudit( query );
|
|
655
|
+
if ( inputData.isExport ) {
|
|
656
|
+
await download( result, res );
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
660
|
+
} catch ( error ) {
|
|
661
|
+
const err = error.error || 'Internal Server Error';
|
|
662
|
+
logger.info( { error: error, message: req.body, function: 'clientMetrics' } );
|
|
663
|
+
return res.sendError( err, 500 );
|
|
664
|
+
}
|
|
665
|
+
}
|
|
@@ -1,61 +1,26 @@
|
|
|
1
1
|
import { logger } from 'tango-app-api-middleware';
|
|
2
|
-
import {
|
|
2
|
+
import { aggregateStore } from '../service/store.service.js';
|
|
3
3
|
|
|
4
4
|
export async function auditStoreList( req, res ) {
|
|
5
5
|
try {
|
|
6
|
-
const inputData = req.
|
|
6
|
+
const inputData = req.body;
|
|
7
7
|
const query =[
|
|
8
8
|
{
|
|
9
9
|
$match: {
|
|
10
|
-
clientId: { $
|
|
11
|
-
fileDate: { $eq: inputData.fileDate },
|
|
10
|
+
clientId: { $in: inputData.clientId },
|
|
12
11
|
},
|
|
13
12
|
},
|
|
14
13
|
{
|
|
15
14
|
$project: {
|
|
16
15
|
_id: 0,
|
|
17
|
-
clientName: 1,
|
|
18
16
|
clientId: 1,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
$lookup: {
|
|
24
|
-
from: 'stores',
|
|
25
|
-
let: { storeList: '$storeList' },
|
|
26
|
-
pipeline: [
|
|
27
|
-
{
|
|
28
|
-
$match: {
|
|
29
|
-
$expr: {
|
|
30
|
-
$in: [ '$storeId', '$$storeList' ],
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
$project: {
|
|
36
|
-
_id: 1,
|
|
37
|
-
storeId: 1,
|
|
38
|
-
storeName: 1,
|
|
39
|
-
clientId: 1,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
], as: 'stores',
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
$unwind: { path: '$stores', preserveNullAndEmptyArrays: true },
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
$project: {
|
|
51
|
-
storeName: '$stores.storeName',
|
|
52
|
-
storeId: '$stores.storeId',
|
|
53
|
-
clientId: '$clientId',
|
|
17
|
+
storeId: 1,
|
|
18
|
+
storeName: 1,
|
|
54
19
|
},
|
|
55
20
|
},
|
|
56
21
|
];
|
|
57
22
|
|
|
58
|
-
const count = await
|
|
23
|
+
const count = await aggregateStore( query );
|
|
59
24
|
if ( count.length == 0 ) {
|
|
60
25
|
return res.sendSuccess( { result: [], count: 0 } );
|
|
61
26
|
}
|
|
@@ -66,12 +31,12 @@ export async function auditStoreList( req, res ) {
|
|
|
66
31
|
{ $limit: limit },
|
|
67
32
|
);
|
|
68
33
|
}
|
|
69
|
-
const
|
|
34
|
+
const result = await aggregateStore( query );
|
|
70
35
|
|
|
71
|
-
return res.sendSuccess( { result:
|
|
36
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
72
37
|
} catch ( error ) {
|
|
73
38
|
const err = error.message || 'Internal Server Error';
|
|
74
|
-
logger.info( { error: error, messgae: req.
|
|
39
|
+
logger.info( { error: error, messgae: req.body, function: 'auditStoreList' } );
|
|
75
40
|
return res.sendError( err, 500 );
|
|
76
41
|
}
|
|
77
42
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
|
+
import { aggregateUser } from '../service/user.service.js';
|
|
3
|
+
|
|
4
|
+
export async function auditUserList( req, res ) {
|
|
5
|
+
try {
|
|
6
|
+
const inputData = req.query;
|
|
7
|
+
const query =[
|
|
8
|
+
{
|
|
9
|
+
$match: {
|
|
10
|
+
userType: { $eq: 'tango' },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
$project: {
|
|
15
|
+
userName: 1,
|
|
16
|
+
userId: '$_id',
|
|
17
|
+
_id: 0,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const count = await aggregateUser( query );
|
|
23
|
+
if ( count.length == 0 ) {
|
|
24
|
+
return res.sendSuccess( { result: [], count: 0 } );
|
|
25
|
+
}
|
|
26
|
+
if ( inputData.limit ) {
|
|
27
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
28
|
+
query.push(
|
|
29
|
+
{ $skip: offset },
|
|
30
|
+
{ $limit: limit },
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const result = await aggregateUser( query );
|
|
34
|
+
|
|
35
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
36
|
+
} catch ( error ) {
|
|
37
|
+
const err = error.message || 'Internal Server Error';
|
|
38
|
+
logger.info( { error: error, messgae: req.query, function: 'auditUserList' } );
|
|
39
|
+
return res.sendError( err, 500 );
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { clientMetricsSchema, getAuditImagesSchema, storeMetricsSchema, userAuditHistorySchema } from '../dtos/auditMetrics.dtos.js';
|
|
2
|
+
import { clientMetricsSchema, getAuditImagesSchema, storeMetricsSchema, userAuditHistorySchema, userMetricsSchema } from '../dtos/auditMetrics.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const auditMetricsDocs = {
|
|
5
5
|
|
|
@@ -91,4 +91,26 @@ export const auditMetricsDocs = {
|
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
|
+
'/v3/audit-metrics/user-metrics': {
|
|
95
|
+
post: {
|
|
96
|
+
tags: [ 'Audit Metrics' ],
|
|
97
|
+
description: `Get list of file wise details with date range and users`,
|
|
98
|
+
operationId: 'client-metrics',
|
|
99
|
+
parameters: {},
|
|
100
|
+
requestBody: {
|
|
101
|
+
content: {
|
|
102
|
+
'application/json': {
|
|
103
|
+
schema: j2s( userMetricsSchema ).swagger,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
responses: {
|
|
108
|
+
200: { description: 'Successful' },
|
|
109
|
+
401: { description: 'Unauthorized User' },
|
|
110
|
+
422: { description: 'Field Error' },
|
|
111
|
+
500: { description: 'Server Error' },
|
|
112
|
+
204: { description: 'Not Found' },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
94
116
|
};
|
package/src/docs/store.docs.js
CHANGED
|
@@ -3,36 +3,18 @@ import { auditStoreSchema } from '../dtos/store.dtos.js';
|
|
|
3
3
|
|
|
4
4
|
export const storeDocs = {
|
|
5
5
|
'/v3/audit/store/audit-stores': {
|
|
6
|
-
|
|
7
|
-
tags: [ 'Audit/
|
|
8
|
-
description:
|
|
9
|
-
operationId: '
|
|
10
|
-
parameters:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
post: {
|
|
7
|
+
tags: [ 'Audit/Stores' ],
|
|
8
|
+
description: `sGet list of stores`,
|
|
9
|
+
operationId: 'audit-stores',
|
|
10
|
+
parameters: {},
|
|
11
|
+
requestBody: {
|
|
12
|
+
content: {
|
|
13
|
+
'application/json': {
|
|
14
|
+
schema: j2s( auditStoreSchema ).swagger,
|
|
15
|
+
},
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
in: 'query',
|
|
19
|
-
name: 'fileDate',
|
|
20
|
-
scema: j2s( auditStoreSchema ).swagger,
|
|
21
|
-
require: true,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
in: 'query',
|
|
25
|
-
name: 'limit',
|
|
26
|
-
scema: j2s( auditStoreSchema ).swagger,
|
|
27
|
-
require: false,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
in: 'query',
|
|
31
|
-
name: 'offset',
|
|
32
|
-
scema: j2s( auditStoreSchema ).swagger,
|
|
33
|
-
require: false,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
17
|
+
},
|
|
36
18
|
responses: {
|
|
37
19
|
200: { description: 'Successful' },
|
|
38
20
|
401: { description: 'Unauthorized User' },
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import j2s from 'joi-to-swagger';
|
|
2
|
+
import { userSchema } from '../dtos/user.dtos.js';
|
|
3
|
+
|
|
4
|
+
export const userDocs = {
|
|
5
|
+
'/v3/audit/user/tango-users': {
|
|
6
|
+
get: {
|
|
7
|
+
tags: [ 'Audit/User' ],
|
|
8
|
+
description: 'Get user list',
|
|
9
|
+
operationId: 'tango-users',
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
in: 'query',
|
|
13
|
+
name: 'limit',
|
|
14
|
+
scema: j2s( userSchema ).swagger,
|
|
15
|
+
require: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
in: 'query',
|
|
19
|
+
name: 'offset',
|
|
20
|
+
scema: j2s( userSchema ).swagger,
|
|
21
|
+
require: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
responses: {
|
|
25
|
+
200: { description: 'Successful' },
|
|
26
|
+
401: { description: 'Unauthorized User' },
|
|
27
|
+
422: { description: 'Field Error' },
|
|
28
|
+
500: { description: 'Server Error' },
|
|
29
|
+
204: { description: 'Not Found' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -55,7 +55,6 @@ export const saveSchema = joi.object(
|
|
|
55
55
|
storeId: joi.string().required(),
|
|
56
56
|
fileDate: joi.string().required(),
|
|
57
57
|
auditType: joi.string().required(),
|
|
58
|
-
fileDate: joi.string().required(),
|
|
59
58
|
beforeCount: joi.number().required(),
|
|
60
59
|
junkCount: joi.number().required(),
|
|
61
60
|
junk: joi.array().required(),
|
|
@@ -74,3 +74,23 @@ export const clientMetricsSchema = joi.object(
|
|
|
74
74
|
export const clientMetricsValid = {
|
|
75
75
|
body: clientMetricsSchema,
|
|
76
76
|
};
|
|
77
|
+
|
|
78
|
+
export const userMetricsSchema = joi.object(
|
|
79
|
+
{
|
|
80
|
+
fromDate: joi.string().required(),
|
|
81
|
+
toDate: joi.string().required(),
|
|
82
|
+
fileType: joi.string().required(),
|
|
83
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
84
|
+
filterByUser: joi.array().optional(),
|
|
85
|
+
filterByStatus: joi.array().optional(),
|
|
86
|
+
sortColumnName: joi.string().optional(),
|
|
87
|
+
sortBy: joi.number().optional(),
|
|
88
|
+
limit: joi.number().optional(),
|
|
89
|
+
offset: joi.number().optional(),
|
|
90
|
+
isExport: joi.boolean().optional(),
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export const userMetricsValid = {
|
|
95
|
+
body: userMetricsSchema,
|
|
96
|
+
};
|
package/src/dtos/store.dtos.js
CHANGED
|
@@ -3,13 +3,12 @@ import joi from 'joi';
|
|
|
3
3
|
|
|
4
4
|
export const auditStoreSchema = joi.object(
|
|
5
5
|
{
|
|
6
|
-
clientId: joi.
|
|
7
|
-
fileDate: joi.string().required(),
|
|
6
|
+
clientId: joi.array().required(),
|
|
8
7
|
limit: joi.number().optional(),
|
|
9
8
|
offset: joi.number().optional(),
|
|
10
9
|
},
|
|
11
10
|
);
|
|
12
11
|
|
|
13
12
|
export const auditStoreValid = {
|
|
14
|
-
|
|
13
|
+
body: auditStoreSchema,
|
|
15
14
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { clientMetrics, getAuditImageList, storeMetrics, userAuditHistory } from '../controllers/auditMetrics.controllers.js';
|
|
5
|
-
import { clientMetricsValid, getAuditImagesValid, storeMetricsValid, userAuditHistoryValid } from '../dtos/auditMetrics.dtos.js';
|
|
4
|
+
import { clientMetrics, getAuditImageList, storeMetrics, userAuditHistory, userMetrics } from '../controllers/auditMetrics.controllers.js';
|
|
5
|
+
import { clientMetricsValid, getAuditImagesValid, storeMetricsValid, userAuditHistoryValid, userMetricsValid } from '../dtos/auditMetrics.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditMetricsRouter = express.Router();
|
|
8
8
|
|
|
@@ -10,5 +10,6 @@ auditMetricsRouter.post( '/get-audit-images', validate( getAuditImagesValid ), g
|
|
|
10
10
|
auditMetricsRouter.post( '/user-audit-history', validate( userAuditHistoryValid ), isAllowedSessionHandler, userAuditHistory );
|
|
11
11
|
auditMetricsRouter.post( '/store-metrics', validate( storeMetricsValid ), isAllowedSessionHandler, storeMetrics );
|
|
12
12
|
auditMetricsRouter.post( '/client-metrics', validate( clientMetricsValid ), isAllowedSessionHandler, clientMetrics );
|
|
13
|
+
auditMetricsRouter.post( '/user-metrics', validate( userMetricsValid ), isAllowedSessionHandler, userMetrics );
|
|
13
14
|
|
|
14
15
|
export default auditMetricsRouter;
|
|
@@ -5,6 +5,6 @@ import { auditStoreValid } from '../dtos/store.dtos.js';
|
|
|
5
5
|
|
|
6
6
|
export const storeRouter = Router();
|
|
7
7
|
|
|
8
|
-
storeRouter.
|
|
8
|
+
storeRouter.post( '/audit-stores', isAllowedSessionHandler, validate( auditStoreValid ), auditStoreList );
|
|
9
9
|
|
|
10
10
|
export default storeRouter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
|
+
import { auditUserList } from '../controllers/user.controllers.js';
|
|
4
|
+
|
|
5
|
+
export const userRouter = Router();
|
|
6
|
+
|
|
7
|
+
userRouter.get( '/tango-users', isAllowedSessionHandler, auditUserList );
|
|
8
|
+
|
|
9
|
+
export default userRouter;
|
|
@@ -4,3 +4,7 @@ import storeModel from 'tango-api-schema/schema/store.model.js';
|
|
|
4
4
|
export function findOneStore( query, fields ) {
|
|
5
5
|
return storeModel.findOne( query, fields );
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export function aggregateStore( query, fields ) {
|
|
9
|
+
return storeModel.aggregate( query, fields );
|
|
10
|
+
}
|