tango-app-api-trax 3.7.12-qid-3 → 3.7.12-qid-5

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.7.12-qid-3",
3
+ "version": "3.7.12-qid-5",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,6 +23,7 @@ import { sendPushNotification, sendAiPushNotification } from 'tango-app-api-midd
23
23
  import * as clusterServices from '../services/cluster.service.js';
24
24
  import * as teamsServices from '../services/teams.service.js';
25
25
  import * as notificationModel from '../services/notification.service.js';
26
+ import * as runAIRequestServices from '../services/runAIRequest.services.js';
26
27
 
27
28
  const ObjectId = mongoose.Types.ObjectId;
28
29
  dayjs.extend( customParseFormat );
@@ -2581,3 +2582,37 @@ export async function countUpdateRunAI( req, res ) {
2581
2582
  return res.sendError( e, 500 );
2582
2583
  }
2583
2584
  }
2585
+
2586
+ export async function getRunAIQuestions( req, res ) {
2587
+ try {
2588
+ let requestData = req.body;
2589
+
2590
+ let getQuery = {};
2591
+ if ( requestData.clientId && requestData.clientId != '' ) {
2592
+ getQuery.clientId = requestData.clientId;
2593
+ }
2594
+ if ( requestData.checkListId && requestData.checkListId != '' ) {
2595
+ getQuery.checkListId = requestData.checkListId;
2596
+ }
2597
+ if ( requestData.checkListName && requestData.checkListName != '' ) {
2598
+ getQuery.checkListName = requestData.checkListName;
2599
+ }
2600
+ let projectData = {};
2601
+ if ( requestData.projectValue && requestData.projectValue != '' ) {
2602
+ let projectArray = requestData.projectValue.split( ',' ).map( ( f ) => f.trim() );
2603
+ if ( projectArray.length ) {
2604
+ projectArray.forEach( ( key ) => {
2605
+ projectData[key] = 1; // <-- use [] to assign dynamic keys
2606
+ } );
2607
+ }
2608
+ }
2609
+ let getDetails = await runAIRequestServices.find( getQuery, projectData );
2610
+ if ( !getDetails || !getDetails.length ) {
2611
+ return res.sendError( 'No data found', 204 );
2612
+ }
2613
+ return res.sendSuccess( { count: getDetails.length, questions: getDetails } );
2614
+ } catch ( e ) {
2615
+ logger.error( { functionName: 'getRunAIQuestions', error: e } );
2616
+ return res.sendError( e, 500 );
2617
+ }
2618
+ }
@@ -863,6 +863,17 @@ export const duplicateChecklist = async ( req, res ) => {
863
863
  sectionDetails.checkList = dupDetails.checkListName;
864
864
  sectionDetails.createdAt = new Date();
865
865
  sectionDetails.updatedAt = new Date();
866
+ for ( let j = 0; j < sectionDetails.question.length; j++ ) {
867
+ let questionArr = sectionDetails.question[j];
868
+ if ( questionArr && questionArr.uniqueqid && questionArr.uniqueqid != '' ) {
869
+ let spliteID = questionArr.uniqueqid.split( '-' );
870
+ questionArr.uniqueqid =
871
+ spliteID[0] + '-' +
872
+ dupDetails.checkListNumber + '-' +
873
+ spliteID[2] + '-' +
874
+ spliteID[3];
875
+ }
876
+ }
866
877
  delete sectionDetails['_id'];
867
878
  sections.push( sectionDetails );
868
879
  }
@@ -870,8 +881,10 @@ export const duplicateChecklist = async ( req, res ) => {
870
881
  let actionType = 'Duplicated';
871
882
  let teamsMsg;
872
883
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
873
- teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
874
- sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
884
+ if ( teamsAlertUrls && teamsAlertUrls !='' ) {
885
+ teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
886
+ sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
887
+ }
875
888
 
876
889
  let logObj = {
877
890
  client_id: checkDetails.client_id,
@@ -1824,6 +1837,7 @@ export const updateConfigure =async ( req, res ) => {
1824
1837
 
1825
1838
  export const updateConfigurev1 =async ( req, res ) => {
1826
1839
  try {
1840
+ console.log( '123' );
1827
1841
  let inputBody = req.body;
1828
1842
  let id;
1829
1843
  let checklistDetails;
@@ -1845,7 +1859,7 @@ export const updateConfigurev1 =async ( req, res ) => {
1845
1859
  }
1846
1860
  }
1847
1861
 
1848
- if ( !inputBody.checkListDetails.assignedUsers.length && inputBody.submitType == 'publish' ) {
1862
+ if ( !inputBody?.checkListDetails?.assignedUsers?.length && inputBody.submitType == 'publish' ) {
1849
1863
  return res.sendError( 'Please Assigned a user', 400 );
1850
1864
  }
1851
1865
 
@@ -27,6 +27,7 @@ internalTraxRouter
27
27
  .post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
28
28
  .post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification )
29
29
  .post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI )
30
- .post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI );
30
+ .post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI )
31
+ .post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions );
31
32
 
32
33