tango-app-api-trax 1.0.0-beta-task.14 → 1.0.0-beta-task.17

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": "1.0.0-beta-task.14",
3
+ "version": "1.0.0-beta-task.17",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "mongodb": "^6.8.0",
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
- "tango-api-schema": "^2.2.5",
30
- "tango-app-api-middleware": "3.1.43-alpha.10",
29
+ "tango-api-schema": "^2.2.7",
30
+ "tango-app-api-middleware": "^3.1.43-alpha.10",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
33
33
  "winston-daily-rotate-file": "^5.0.0"
@@ -3,6 +3,7 @@ import { aggregate } from '../services/processedchecklist.services.js';
3
3
  import dayjs from 'dayjs';
4
4
  import * as processedchecklistService from '../services/processedchecklist.services.js';
5
5
  import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
6
+ import * as checklistconfigService from '../services/checklist.service.js';
6
7
 
7
8
 
8
9
  import utc from 'dayjs/plugin/utc.js';
@@ -608,13 +609,23 @@ export const flagCardsV1 = async ( req, res ) => {
608
609
  if ( data.questionFlag ) flagCards.questionFlag.count = data.questionFlag;
609
610
  if ( data.delayInSubmission ) flagCards.delayInSubmission.count = data.delayInSubmission;
610
611
 
612
+ const publishedAiChecklists = await checklistconfigService.find( { client_id: clientId, publish: true, checkListType: { $ne: 'custom' } }, { checkListType: 1 } );
613
+
614
+ if ( !publishedAiChecklists?.length ) {
615
+ return res.sendError( { error: 'No Data Found' }, 204 );
616
+ }
617
+
611
618
  const detectionPayload = { fromDate, toDate, storeId, clientId };
612
619
  const lambdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
613
620
  const resultData = await LamdaServiceCall( lambdaURL, detectionPayload );
614
621
 
622
+ const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
623
+
615
624
  if ( resultData && resultData.status_code === '200' ) {
616
- flagCards.detectionFlag.count = resultData.totalDetection;
617
- flagCards.totalFlag += flagCards.detectionFlag.count;
625
+ published.forEach( ( item ) => {
626
+ flagCards.detectionFlag.count += resultData[item];
627
+ } );
628
+ flagCards.totalFlag = flagCards.detectionFlag.count;
618
629
  }
619
630
 
620
631
  return res.sendSuccess( { flagCards } );
@@ -726,11 +737,21 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
726
737
 
727
738
  console.log( dayjs( toDate ).startOf( 'day' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'new start of' );
728
739
 
740
+ const publishedAiChecklists = await checklistconfigService.find( { client_id: requestData.clientId, publish: true, checkListType: { $ne: 'custom' } }, { checkListType: 1 } );
741
+
742
+ if ( !publishedAiChecklists?.length ) {
743
+ return 0;
744
+ }
745
+
729
746
  const LamdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
730
747
  const resultData = await LamdaServiceCall( LamdaURL, detectionPayload );
731
748
 
749
+ const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
750
+
732
751
  if ( resultData?.status_code === '200' ) {
733
- return resultData.totalDetection;
752
+ let result = 0;
753
+ published.forEach( ( item ) => result += resultData[item] );
754
+ return result;
734
755
  }
735
756
  return 0;
736
757
  };
@@ -530,7 +530,7 @@ export const duplicateChecklist = async ( req, res ) => {
530
530
 
531
531
  let dupDetails = { ...checkDetails._doc };
532
532
  let name = `^${dupDetails.checkListName.split( '(' )[0]}\\(.*\\)$`;
533
- let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.query.clientId, type: 'checklist', isdeleted: false } );
533
+ let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.query.clientId, type: 'checklist' } );
534
534
  if ( checkListNameDetails.length ) {
535
535
  let nameLength = checkListNameDetails.length + 1;
536
536
  dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength +')';