tango-app-api-audit 1.0.19 → 1.0.20

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": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -532,14 +532,25 @@ export async function userMetrics( req, res ) {
532
532
  $and: filter,
533
533
  },
534
534
  },
535
+ {
536
+ $project: {
537
+ userId: 1,
538
+ fileDate: 1,
539
+ checkIntime: 1,
540
+ checkOutTime: 1,
541
+ totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
542
+ beforeCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$beforeCount', 0 ] },
543
+ afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
544
+ },
545
+ },
535
546
  {
536
547
  $group: {
537
548
  _id: { userId: '$userId', fileDate: '$fileDate' },
538
549
  userId: { $first: '$userId' },
539
550
  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 ] } } ] },
551
+ totalCompletedFiles: { $sum: '$totalCompletedFiles' },
552
+ beforeCount: { $sum: '$beforeCount' },
553
+ afterCount: { $sum: '$afterCount' },
543
554
  checkIntime: { $first: '$createdAt' },
544
555
  checkOutTime: { $last: '$createdAt' },
545
556
 
@@ -556,7 +567,7 @@ export async function userMetrics( req, res ) {
556
567
  afterCount: 1,
557
568
  mappingPerc: { $round: [
558
569
  { $multiply: [
559
- { $divide: [ '$afterCount', 'beforeCount' ] }, 100,
570
+ { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
560
571
  ] }, 2,
561
572
  ] },
562
573
  checkIntime: 1,