tango-app-api-trax 3.8.8 → 3.8.10

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.8.8",
3
+ "version": "3.8.10",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -124,16 +124,18 @@ export async function getcustomerunattendedlist( req, res ) {
124
124
  try {
125
125
  let config = [];
126
126
  if ( req.body.ChecklistType == 'storeopenandclose' ) {
127
- config = await processedchecklistconfigService.find( { date_string: { $gte: req.body.fromDate, $lte: req.body.toDate }, checkListType: req.body.ChecklistType }, { date_string: 1, aiConfig: 1 } );
128
- req.body.liveDate = [];
129
- req.body.eodDate = [];
127
+ config = await processedchecklistconfigService.find( { date_string: { $gte: req.body.fromDate, $lte: req.body.toDate }, checkListType: req.body.ChecklistType, client_id: req.body?.clientId }, { date_string: 1, aiConfig: 1 } );
128
+ req.body.liveDate = new Set();
129
+ req.body.eodDate = new Set();
130
130
  config.forEach( ( data ) => {
131
131
  if ( data?.aiConfig?.advancedConfig?.dataProcessing == 'live' ) {
132
- req.body.liveDate.push( data.date_string );
132
+ req.body.liveDate.add( data.date_string );
133
133
  } else {
134
- req.body.eodDate.push( data.date_string );
134
+ req.body.eodDate.add( data.date_string );
135
135
  }
136
136
  } );
137
+ req.body.liveDate = [ ...req.body.liveDate ];
138
+ req.body.eodDate = [ ...req.body.eodDate ];
137
139
  }
138
140
  let url = JSON.parse( process.env.LAMBDAURL );
139
141
  let resultData = await LamdaServiceCall( url.customerUnattended, req.body );
@@ -2151,7 +2151,7 @@ export async function AiPushNotificationAlert( req, res ) {
2151
2151
  export async function liveAiPushNotificationAlert( req, res ) {
2152
2152
  try {
2153
2153
  let findAichecklist = await CLconfig.findOne( { checkListType: req.body.checkListType, client_id: req.body.client_id }, { aiConfig: 1 } );
2154
- if ( findAichecklist?.aiConfig?.alertConfig?.alertSendTo?.mobile.length ) {
2154
+ if ( findAichecklist?.aiConfig?.alertConfig?.alertSendTo?.enabled && findAichecklist?.aiConfig?.alertConfig?.alertSendTo?.mobile.length ) {
2155
2155
  for ( let user of findAichecklist?.aiConfig?.alertConfig?.alertSendTo?.mobile ) {
2156
2156
  let findOneUser = await userService.findOne( { email: user.value }, { fcmToken: 1 } );
2157
2157
  if ( findOneUser&&findOneUser.fcmToken&&findOneUser.fcmToken!='' ) {
@@ -4041,7 +4041,13 @@ export async function sendAIEmailList( req, res ) {
4041
4041
  try {
4042
4042
  let spocList = [];
4043
4043
  let result = [];
4044
+ let assignStoreList = [];
4044
4045
  let getChecklistDetails = await CLconfig.findOne( { client_id: req.body.clientId, publish: true, checkListName: req.body.checklistName }, { aiConfig: 1 } );
4046
+ if ( !getChecklistDetails ) {
4047
+ return res.sendError( 'No data found', 204 );
4048
+ }
4049
+ let assignList = await CLassign.find( { checkListId: getChecklistDetails._id, isdeleted: false } );
4050
+ assignStoreList = assignList.map( ( store ) => store.store_id );
4045
4051
  if ( getChecklistDetails && getChecklistDetails?.aiConfig?.alertConfig?.alertSendTo?.enabled && getChecklistDetails?.aiConfig?.alertConfig?.alertSendTo?.email?.type?.length ) {
4046
4052
  let userList = [ ...getChecklistDetails?.aiConfig?.alertConfig?.alertSendTo?.email?.users.map( ( ele ) => ele.value ) ];
4047
4053
  if ( getChecklistDetails?.aiConfig?.alertConfig?.alertSendTo?.email?.type.includes( 'store' ) ) {
@@ -4126,12 +4132,16 @@ export async function sendAIEmailList( req, res ) {
4126
4132
  }
4127
4133
  }
4128
4134
  stores = Array.from( storeIds );
4135
+ stores = stores.filter( ( ele ) => assignStoreList.includes( ele ) );
4136
+ } else {
4137
+ stores = assignStoreList;
4129
4138
  }
4130
4139
  let data = {
4131
4140
  id: getChecklistDetails?._id,
4132
4141
  email: email,
4133
4142
  stores,
4134
4143
  role: userDetails.role,
4144
+ storeCount: assignStoreList?.length,
4135
4145
  };
4136
4146
  result.push( data );
4137
4147
  }
@@ -4147,6 +4157,7 @@ export async function sendAIEmailList( req, res ) {
4147
4157
  email: ele.email,
4148
4158
  stores: [ ele.store ],
4149
4159
  role: 'admin',
4160
+ storeCount: assignStoreList?.length,
4150
4161
  } );
4151
4162
  }
4152
4163
  } );