tango-app-api-trax 3.5.2-alpha-12 → 3.5.2-sec-1

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.5.2-alpha-12",
3
+ "version": "3.5.2-sec-1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -280,6 +280,7 @@ export const create = async ( req, res ) => {
280
280
  checkListId: checkListId,
281
281
  question: section.questions,
282
282
  checkList: inputBody.checklistName,
283
+ sectionNumber: section.sectionNumber,
283
284
  };
284
285
  await questionService.create( sectionList ).then( async ( data ) => {
285
286
  if ( i == inputBody.sections.length - 1 ) {
@@ -429,6 +430,7 @@ export const getConfigDetails = async ( req, res ) => {
429
430
  name: item.section,
430
431
  oldName: item?.sectionOldName,
431
432
  questions: item.question,
433
+ sectionNumber: item.sectionNumber,
432
434
  } );
433
435
  } );
434
436
  sectionList = sections;
@@ -906,11 +908,13 @@ export const update = async ( req, res ) => {
906
908
  checkListId: checkListId,
907
909
  question: section.questions,
908
910
  checkList: inputBody.checklistName,
911
+ sectionNumber: section.sectionNumber,
909
912
  } );
910
913
  }
911
914
  }
912
915
  await questionService.deleteMany( { checkListId: checkListId, client_id: req.body.clientId } );
913
916
  if ( sectionList.length ) {
917
+ sectionList.sort( ( a, b ) => a.sectionNumber - b.sectionNumber );
914
918
  await questionService.insertMany( sectionList );
915
919
  }
916
920
 
@@ -1670,6 +1674,7 @@ export const updateConfigurev1 =async ( req, res ) => {
1670
1674
  client_id: req.body.clientId,
1671
1675
  createdByEmail: req.user.email,
1672
1676
  approver: inputBody?.checkListDetails?.approver || [],
1677
+ sections: inputBody?.checkListDetails?.sections || [],
1673
1678
  };
1674
1679
  await checklistLogs.create( logInsertData );
1675
1680
 
@@ -1,4 +1,4 @@
1
- import { logger, download, getChecklistUsers } from 'tango-app-api-middleware';
1
+ import { logger, download, getChecklistUsers, insertOpenSearchData } from 'tango-app-api-middleware';
2
2
  import * as processedchecklistService from '../services/processedchecklist.services.js';
3
3
  import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
4
4
  import * as checklistconfigService from '../services/checklist.service.js';
@@ -1595,6 +1595,7 @@ export const checklistInfo = async ( req, res ) => {
1595
1595
  } },
1596
1596
  approvalByEmail: 1,
1597
1597
  approvalTime_string: 1,
1598
+ _id: 1,
1598
1599
  },
1599
1600
  } );
1600
1601
 
@@ -1645,6 +1646,7 @@ export const checklistInfo = async ( req, res ) => {
1645
1646
  submitCount: 1,
1646
1647
  approvalByEmail: 1,
1647
1648
  approvalTime_string: 1,
1649
+ _id: 1,
1648
1650
  },
1649
1651
  } );
1650
1652
 
@@ -3827,7 +3829,6 @@ export const reinitiatechecklist = async ( req, res ) => {
3827
3829
  let requestData = req.body;
3828
3830
  let findQuery = [];
3829
3831
  let findAndQuery = [];
3830
-
3831
3832
  if ( requestData._id ) {
3832
3833
  findAndQuery.push(
3833
3834
  { _id: new mongoose.Types.ObjectId( requestData._id ) },
@@ -3837,6 +3838,15 @@ export const reinitiatechecklist = async ( req, res ) => {
3837
3838
  $project: {
3838
3839
  _id: 1,
3839
3840
  reinitiateStatus: 1,
3841
+ store_id: 1,
3842
+ storeName: 1,
3843
+ userEmail: 1,
3844
+ action: 1,
3845
+ sourceCheckList_id: 1,
3846
+ checkListName: 1,
3847
+ client_id: 1,
3848
+ date_iso: 1,
3849
+ coverage: 1,
3840
3850
  },
3841
3851
  } );
3842
3852
  let getChecklist = await processedchecklistService.aggregate( findQuery );
@@ -3844,7 +3854,26 @@ export const reinitiatechecklist = async ( req, res ) => {
3844
3854
  let updateChecklist = await processedchecklistService.updateOne( { _id: new mongoose.Types.ObjectId( requestData._id ) }, { reinitiateStatus: true } );
3845
3855
  if ( updateChecklist ) {
3846
3856
  // Delete Time Flag Detection //
3847
-
3857
+ const data = getChecklist[0];
3858
+ let logObj = {
3859
+ client_id: data.client_id,
3860
+ createAt: new Date(),
3861
+ sourceCheckList_id: data.sourceCheckList_id,
3862
+ checkListName: data.checkListName,
3863
+ fromCheckListName: '',
3864
+ type: 'checklist',
3865
+ action: 'reinitiated',
3866
+ storeName: data.storeName,
3867
+ store_id: data.store_id,
3868
+ userEmail: data.userEmail,
3869
+ createdByEmail: req.user.email,
3870
+ createdBy: req.user.userName,
3871
+ coverage: data.coverage,
3872
+ logDetails: {},
3873
+ userType: req.user.userType,
3874
+ processedChecklistId: data._id,
3875
+ };
3876
+ insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
3848
3877
  return res.sendSuccess( 'Reinitiate Successfully' );
3849
3878
  } else {
3850
3879
  return res.sendError( { error: 'Something Went wrong Please Try Again' }, 400 );
@@ -3854,25 +3883,65 @@ export const reinitiatechecklist = async ( req, res ) => {
3854
3883
  }
3855
3884
  } else if ( requestData.sourceCheckList_id ) {
3856
3885
  findAndQuery.push(
3857
- { _id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
3886
+ {
3887
+ reinitiateStatus: false,
3888
+ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
3889
+ },
3858
3890
  );
3859
3891
  findQuery.push( { $match: { $and: findAndQuery } } );
3860
3892
  findQuery.push( {
3861
3893
  $project: {
3862
3894
  _id: 1,
3863
3895
  reinitiateStatus: 1,
3896
+ store_id: 1,
3897
+ storeName: 1,
3898
+ userEmail: 1,
3899
+ action: 1,
3900
+ sourceCheckList_id: 1,
3901
+ checkListName: 1,
3902
+ client_id: 1,
3903
+ date_iso: 1,
3904
+ coverage: 1,
3864
3905
  },
3865
3906
  } );
3866
3907
  let getChecklist = await processedchecklistService.aggregate( findQuery );
3867
3908
  if ( getChecklist.length>0 ) {
3868
3909
  let updateQuery = {
3869
- _id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
3910
+ sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
3870
3911
  timeFlag: { $gt: 0 },
3912
+ reinitiateStatus: false,
3871
3913
  };
3872
3914
  let updateChecklist = await processedchecklistService.updateMany( updateQuery, { reinitiateStatus: true } );
3873
3915
  if ( updateChecklist ) {
3874
3916
  // Delete Time Flag Detection //
3875
-
3917
+ const data = getChecklist[0];
3918
+ // let stores = getChecklist.map( ( item ) => ( {
3919
+ // // store_id: item.store_id,
3920
+ // storeName: item.storeName,
3921
+ // } ) );
3922
+
3923
+ // let users = getChecklist.map( ( item ) => ( {
3924
+ // userEmail: item.userEmail,
3925
+ // } ) );
3926
+ let logObj = {
3927
+ client_id: data.client_id,
3928
+ createAt: new Date(),
3929
+ sourceCheckList_id: data.sourceCheckList_id,
3930
+ checkListName: data.checkListName,
3931
+ fromCheckListName: '',
3932
+ type: 'checklist',
3933
+ action: 'reinitiated',
3934
+ storeName: data.storeName,
3935
+ store_id: data.store_id,
3936
+ userEmail: data.userEmail,
3937
+ createdByEmail: req.user.email,
3938
+ createdBy: req.user.userName,
3939
+ coverage: data.coverage,
3940
+ logDetails: {},
3941
+ userType: req.user.userType,
3942
+ processedChecklistId: data._id,
3943
+ };
3944
+ insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
3876
3945
  return res.sendSuccess( 'Reinitiate Successfully' );
3877
3946
  } else {
3878
3947
  return res.sendError( { error: 'Something Went wrong Please Try Again' }, 400 );