tango-app-api-trax 3.9.59 → 3.9.61

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-trax",
3
- "version": "3.9.59",
3
+ "version": "3.9.61",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -31,7 +31,7 @@
31
31
  "puppeteer": "^24.39.1",
32
32
  "swagger-ui-express": "^5.0.1",
33
33
  "tango-api-schema": "^2.6.30",
34
- "tango-app-api-middleware": "^3.5.2",
34
+ "tango-app-api-middleware": "^3.6.19",
35
35
  "url": "^0.11.4",
36
36
  "winston": "^3.13.1",
37
37
  "winston-daily-rotate-file": "^5.0.0"
@@ -2027,7 +2027,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2027
2027
  if ( resultData?.status_code === '200' ) {
2028
2028
  let result = 0;
2029
2029
  let ai = 0;
2030
- if ( !publishedAiChecklists?.length ) {
2030
+ if ( publishedAiChecklists?.length ) {
2031
2031
  published.forEach( ( item ) => {
2032
2032
  if ( resultData[item] ) {
2033
2033
  result += resultData[item];
@@ -12,6 +12,7 @@ import * as processedchecklistConfig from '../services/processedchecklistconfig.
12
12
  import * as processedchecklist from '../services/processedchecklist.services.js';
13
13
  // import * as checklistLogs from '../services/checklistlog.service.js';
14
14
  import * as tagService from '../services/tagging.service.js';
15
+ import * as cameraService from '../services/camera.service.js';
15
16
  import * as alertsServices from '../services/clientRequest.service.js';
16
17
  import * as traxApprover from '../services/approver.service.js';
17
18
  const ObjectId = mongoose.Types.ObjectId;
@@ -651,11 +652,50 @@ export const zoneList = async ( req, res ) => {
651
652
  ];
652
653
  let zoneList = await tagService.aggregate( query );
653
654
 
654
- if ( !zoneList.length ) {
655
+
656
+ let cameraQuery = [
657
+ {
658
+ $match: {
659
+ 'clientId': inputBody.clientId,
660
+ 'taggedChecklist.checkListName': inputBody.checkListName,
661
+ },
662
+ },
663
+ // taggedChecklist is an array of objects → unwind to one element per doc
664
+ { $unwind: '$taggedChecklist' },
665
+ // keep only the elements matching the requested checklist
666
+ {
667
+ $match: {
668
+ 'taggedChecklist.checkListName': inputBody.checkListName,
669
+ },
670
+ },
671
+ {
672
+ $project: {
673
+ _id: 0,
674
+ zone: '$taggedChecklist.checkListName', // expose checkListName under the same `zone` key
675
+ },
676
+ },
677
+ {
678
+ $group: {
679
+ _id: '',
680
+ zone: { $addToSet: '$zone' },
681
+ },
682
+ },
683
+ {
684
+ $project: {
685
+ _id: 0,
686
+ zone: 1,
687
+ },
688
+ },
689
+ ];
690
+ let cameraList = await cameraService.aggregate( cameraQuery );
691
+
692
+ let mergedData = [ ...zoneList, ...cameraList ];
693
+
694
+ if ( !mergedData.length ) {
655
695
  return res.sendError( 'no data found', 204 );
656
696
  }
657
697
 
658
- return res.sendSuccess( zoneList );
698
+ return res.sendSuccess( mergedData );
659
699
  } else if ( inputBody.checkListName && allowedChecklistsStreams.includes( inputBody.checkListName ) ) {
660
700
  return res.sendSuccess( [ { zone: 'Camera Angle Change Compliance' } ] );
661
701
  } else {
@@ -686,7 +726,7 @@ export const zoneList = async ( req, res ) => {
686
726
  }
687
727
  };
688
728
 
689
- async function createUser( data ) {
729
+ export async function createUser( data ) {
690
730
  try {
691
731
  let params = {
692
732
  userName: data.userName,
@@ -428,11 +428,16 @@ export const checklistPerformance = async ( req, res ) => {
428
428
  $cond: [
429
429
  { $gt: [ '$$divisor', 0 ] },
430
430
  {
431
- $round: [
431
+ $max: [
432
432
  {
433
- $multiply: [
434
- { $divide: [ '$userComplianceCountTotal', '$$divisor' ] },
435
- 100,
433
+ $round: [
434
+ {
435
+ $multiply: [
436
+ { $divide: [ '$userComplianceCountTotal', '$$divisor' ] },
437
+ 100,
438
+ ],
439
+ },
440
+ 0,
436
441
  ],
437
442
  },
438
443
  0,