tango-app-api-trax 3.7.31 → 3.7.33

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.31",
3
+ "version": "3.7.33",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2685,3 +2685,33 @@ export async function updateChecklistConfig( req, res ) {
2685
2685
  return res.sendError( e, 500 );
2686
2686
  }
2687
2687
  }
2688
+
2689
+ export async function submittedList( req, res ) {
2690
+ try {
2691
+ let getSubmitChecklist = await processedchecklist.find( { checklistStatus: 'submit', date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, { _id: 1 } );
2692
+ let getSubmitTask = await processedTaskService.find( { checklistStatus: 'submit', date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ), isPlano: { $exists: false } }, { _id: 1 } );
2693
+
2694
+ let result = [ ...getSubmitChecklist?.map( ( ele ) => ele?._id ), ...getSubmitTask?.map( ( ele ) => ele?._id ) ];
2695
+ return res.sendSuccess( result );
2696
+ } catch ( e ) {
2697
+ logger.error( { functionName: 'submittedList', error: e } );
2698
+ return res.sendError( e, 500 );
2699
+ }
2700
+ }
2701
+
2702
+
2703
+ export async function submittedInfo( req, res ) {
2704
+ try {
2705
+ if ( !req.query?.id ) {
2706
+ return res.sendError( 'Id is required', 400 );
2707
+ }
2708
+ let info = await processedchecklist.findOne( { _id: req.query.id } );
2709
+ if ( !info ) {
2710
+ info = await processedTaskService.findOne( { _id: req.query.id } );
2711
+ }
2712
+ return res.sendSuccess( info );
2713
+ } catch ( e ) {
2714
+ logger.error( { functionName: 'getTaskCHecklistDetails', error: e } );
2715
+ return res.sendError( e, 500 );
2716
+ }
2717
+ }
@@ -2095,8 +2095,32 @@ export async function submitTask( req, res ) {
2095
2095
  }
2096
2096
 
2097
2097
  const updateResult = await processedTask.updateOne( updateQuery, updateData );
2098
+ if ( submittype == 'submit' ) {
2099
+ updateOpenSearchTask( user, requestData );
2100
+ }
2098
2101
 
2099
2102
  if ( updateResult.modifiedCount > 0 ) {
2103
+ let openSearch = JSON.parse( process.env.OPENSEARCH );
2104
+ let inserttraxlogs = {
2105
+ client_id: req.user.clientId,
2106
+ createAt: new Date(),
2107
+ sourceCheckList_id: checklist.sourceCheckList_id,
2108
+ checkListName: checklist.checkListName,
2109
+ type: 'task',
2110
+ action: requestData?.submittype === 'draft' ? 'save' : 'submit',
2111
+ storeName: checklist.storeName,
2112
+ store_id: checklist.store_id,
2113
+ userName: checklist.userName,
2114
+ userEmail: checklist.userEmail,
2115
+ createdByEmail: checklist.userEmail,
2116
+ createdBy: checklist.userName,
2117
+ coverage: checklist.coverage,
2118
+ checkListType: checklist.checkListType,
2119
+ logDetails: {},
2120
+ userType: req.user.userType,
2121
+ };
2122
+ console.log( 'inserttraxlogs =>', inserttraxlogs );
2123
+ insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
2100
2124
  if ( submittype === 'submit' ) {
2101
2125
  const excludedChecklists = [ 'Store Hygiene Check' ];
2102
2126
  if ( !excludedChecklists.includes( checklist.checkListName ) ) {
@@ -2174,31 +2198,31 @@ export async function submitTask( req, res ) {
2174
2198
  // };
2175
2199
  // await checklistLogs.create( logInsertData );
2176
2200
 
2177
- if ( submittype == 'submit' ) {
2178
- updateOpenSearchTask( user, requestData );
2179
- let openSearch = JSON.parse( process.env.OPENSEARCH );
2180
- // console.log( 'openSearch', openSearch );
2181
- let inserttraxlogs = {
2182
- client_id: req.user.clientId,
2183
- createAt: new Date(),
2184
- sourceCheckList_id: checklist.sourceCheckList_id,
2185
- checkListName: checklist.checkListName,
2186
- type: 'task',
2187
- action: requestData?.submittype === 'draft' ? 'save' : 'submit',
2188
- storeName: checklist.storeName,
2189
- store_id: checklist.store_id,
2190
- userName: checklist.userName,
2191
- userEmail: checklist.userEmail,
2192
- createdByEmail: checklist.userEmail,
2193
- createdBy: checklist.userName,
2194
- coverage: checklist.coverage,
2195
- checkListType: checklist.checkListType,
2196
- logDetails: {},
2197
- userType: req.user.userType,
2198
- };
2199
- console.log( 'inserttraxlogs =>', inserttraxlogs );
2200
- insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
2201
- }
2201
+ // if ( submittype == 'submit' ) {
2202
+ // updateOpenSearchTask( user, requestData );
2203
+ // let openSearch = JSON.parse( process.env.OPENSEARCH );
2204
+ // // console.log( 'openSearch', openSearch );
2205
+ // let inserttraxlogs = {
2206
+ // client_id: req.user.clientId,
2207
+ // createAt: new Date(),
2208
+ // sourceCheckList_id: checklist.sourceCheckList_id,
2209
+ // checkListName: checklist.checkListName,
2210
+ // type: 'task',
2211
+ // action: requestData?.submittype === 'draft' ? 'save' : 'submit',
2212
+ // storeName: checklist.storeName,
2213
+ // store_id: checklist.store_id,
2214
+ // userName: checklist.userName,
2215
+ // userEmail: checklist.userEmail,
2216
+ // createdByEmail: checklist.userEmail,
2217
+ // createdBy: checklist.userName,
2218
+ // coverage: checklist.coverage,
2219
+ // checkListType: checklist.checkListType,
2220
+ // logDetails: {},
2221
+ // userType: req.user.userType,
2222
+ // };
2223
+ // console.log( 'inserttraxlogs =>', inserttraxlogs );
2224
+ // insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
2225
+ // }
2202
2226
 
2203
2227
  return res.sendSuccess( 'Task Updated Successfully' );
2204
2228
  } else {
@@ -30,6 +30,9 @@ internalTraxRouter
30
30
  .post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI )
31
31
  .post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions )
32
32
  .get( '/getRunAIList', isAllowedInternalAPIHandler, internalController.getRunAIList )
33
- .post( '/updateChecklistConfig', isAllowedInternalAPIHandler, internalController.updateChecklistConfig );
33
+ .post( '/updateChecklistConfig', isAllowedInternalAPIHandler, internalController.updateChecklistConfig )
34
+ .get( '/submittedList', isAllowedInternalAPIHandler, internalController.submittedList )
35
+ .get( '/getSubmittedDetails', isAllowedInternalAPIHandler, internalController.submittedInfo )
36
+ ;
34
37
 
35
38