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

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-1",
3
+ "version": "3.7.12-qid-3",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "mongodb": "^6.8.0",
28
28
  "nodemon": "^3.1.4",
29
29
  "path": "^0.12.7",
30
- "tango-api-schema": "^2.3.20",
30
+ "tango-api-schema": "^2.4.5",
31
31
  "tango-app-api-middleware": "^3.5.2",
32
32
  "url": "^0.11.4",
33
33
  "winston": "^3.13.1",
@@ -2947,7 +2947,7 @@ export async function checklistv1( req, res ) {
2947
2947
 
2948
2948
  const [ checklistResult, taskResult ] = await Promise.allSettled( [
2949
2949
  processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
2950
- processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1, refTaskId: 1 } ) ),
2950
+ processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1, refTaskId: 1, store_id: 1 } ) ),
2951
2951
  ] );
2952
2952
 
2953
2953
  const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
@@ -547,7 +547,18 @@ export const flagCardsV1 = async ( req, res ) => {
547
547
  client_id: clientId,
548
548
  // $or: [ { store_id: { $in: storeId } }, { aiStoreList: { $in: storeId } } ],
549
549
  date_iso: { $gte: adjustedFromDate, $lte: adjustedToDate },
550
- $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: storeId } } ],
550
+ // $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: storeId } } ],
551
+ // $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ],
552
+ $or: clientId === '11' ?
553
+ [
554
+ { store_id: { $in: storeId } },
555
+ { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } },
556
+ ] :
557
+ [
558
+ { store_id: { $in: storeId } },
559
+ { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } },
560
+ { aiStoreList: { $in: storeId } },
561
+ ],
551
562
  },
552
563
  },
553
564
  {
@@ -2876,7 +2887,18 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2876
2887
  const createFindQuery = ( fromDate, toDate ) => [
2877
2888
  { $match: { client_id: requestData.clientId,
2878
2889
  date_iso: { $gte: fromDate, $lte: toDate },
2879
- $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ],
2890
+ // $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ],
2891
+ // $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ],
2892
+ $or: requestData.clientId === '11' ?
2893
+ [
2894
+ { store_id: { $in: requestData.storeId } },
2895
+ { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } },
2896
+ ] :
2897
+ [
2898
+ { store_id: { $in: requestData.storeId } },
2899
+ { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } },
2900
+ { aiStoreList: { $in: requestData.storeId } },
2901
+ ],
2880
2902
  } },
2881
2903
  {
2882
2904
  $project: {
@@ -3006,8 +3028,18 @@ export const flagTablesV2 = async ( req, res ) => {
3006
3028
  findAndQuery.push(
3007
3029
  { client_id: requestData.clientId },
3008
3030
  { date_iso: { $gte: fromDate, $lte: toDate } },
3009
- { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ] },
3031
+ // { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ] },
3032
+ // { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
3010
3033
  );
3034
+ if ( requestData.clientId == '11' ) {
3035
+ findAndQuery.push(
3036
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
3037
+ );
3038
+ } else {
3039
+ findAndQuery.push(
3040
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ] },
3041
+ );
3042
+ }
3011
3043
 
3012
3044
  if ( requestData?.filter === 'all' ) {
3013
3045
  findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking' ] } } ] } );
@@ -248,19 +248,39 @@ export const create = async ( req, res ) => {
248
248
  // // }
249
249
  // } );
250
250
 
251
- if ( section.questions && section.questions.length > 0 ) {
252
251
  // Find max uniqueqno (ignore missing values)
253
- let maxQID = Math.max( 0,
254
- ...section.questions .filter( ( q ) => q.uniqueqno !== undefined ) .map( ( q ) => q.uniqueqno ),
255
- );
256
- // Loop through questions
257
- for ( let [ index1, question ] of section.questions.entries() ) {
258
- if ( !question.uniqueqno ) {
259
- maxQID++; // increment
260
- section.questions[index1].uniqueqno = maxQID; // assign new ID
252
+ // if ( section.questions && section.questions.length > 0 ) {
253
+ // let maxQID = Math.max( 0,
254
+ // ...section.questions .filter( ( q ) => q.uniqueqno !== undefined ) .map( ( q ) => q.uniqueqno ),
255
+ // );
256
+ // // Loop through questions
257
+ // for ( let [ index1, question ] of section.questions.entries() ) {
258
+ // if ( !question.uniqueqno ) {
259
+ // maxQID++; // increment
260
+ // section.questions[index1].uniqueqno = maxQID; // assign new ID
261
+ // }
262
+ // if ( !question.uniqueqid ) {
263
+ // section.questions[index1].uniqueqid = req.body.clientId+'-'+ checkNumber+'-'+ section.sectionNumber+'-'+ maxQID; // assign new ID
264
+ // }
265
+ // }
266
+ // }
267
+
268
+ let maxQID = 0;
269
+ if ( section.questions && section.questions.length > 0 ) {
270
+ // let qids = section.questions
271
+ // .filter( ( q ) => q.uniqueqno != null )
272
+ // .map( ( q ) => Number( q.uniqueqno ) );
273
+ // console.log( 'Extracted QIDs =>', qids );
274
+ // let maxQID = Math.max( 0, ...qids );
275
+ // console.log( 'maxQID =>', maxQID );
276
+
277
+ for ( let [ index1, questions ] of section.questions.entries() ) {
278
+ if ( !questions.uniqueqno ) {
279
+ maxQID++;
280
+ section.questions[index1].uniqueqno = maxQID;
261
281
  }
262
- if ( !question.uniqueqid ) {
263
- section.questions[index1].uniqueqid = req.body.clientId+'-'+ checkNumber+'-'+ section.sectionNumber+'-'+ maxQID; // assign new ID
282
+ if ( !questions.uniqueqid ) {
283
+ section.questions[index1].uniqueqid = req.body.clientId + '-' + checkListDetails.checkListNumber + '-' + section.sectionNumber + '-' + maxQID;
264
284
  }
265
285
  }
266
286
  }
@@ -310,6 +330,7 @@ export const create = async ( req, res ) => {
310
330
  question: section.questions,
311
331
  checkList: inputBody.checklistName,
312
332
  sectionNumber: section.sectionNumber,
333
+ maxQuestionNumber: maxQID,
313
334
  };
314
335
  await questionService.create( sectionList ).then( async ( data ) => {
315
336
  if ( i == inputBody.sections.length - 1 ) {
@@ -492,6 +513,7 @@ export const getConfigDetails = async ( req, res ) => {
492
513
  oldName: item?.sectionOldName,
493
514
  questions: item.question,
494
515
  sectionNumber: item.sectionNumber,
516
+ maxQuestionNumber: item?.maxQuestionNumber,
495
517
  } );
496
518
  } );
497
519
  sectionList = sections;
@@ -959,39 +981,37 @@ export const update = async ( req, res ) => {
959
981
  // }
960
982
  // } );
961
983
  // } );
962
- console.log( 'heelos =>' );
963
- if ( section.questions && section.questions.length > 0 ) {
964
- // Find max uniqueqno (cast to number, ignore null/undefined)
965
- console.log( 'section.questions =>', section.questions );
966
- console.log( 'section.questions =>', section.questions[0] );
967
- let qids = section.questions
968
- .filter( ( q ) => q.uniqueqno != null )
969
- .map( ( q ) => Number( q.uniqueqno ) );
970
-
971
- console.log( 'Extracted QIDs =>', qids );
972
984
 
973
- let maxQID = Math.max( 0, ...qids );
974
- console.log( 'maxQID =>', maxQID );
985
+ // Find max uniqueqno (cast to number, ignore null/undefined)
986
+ let maxQID = 0;
987
+ // console.log( 'section.sectionNumber =>', section.sectionNumber );
988
+ // console.log( 'maxQID =>', maxQID );
989
+ if ( section.questions && section.questions.length > 0 ) {
990
+ // let qids = section.questions
991
+ // .filter( ( q ) => q.uniqueqno != null )
992
+ // .map( ( q ) => Number( q.uniqueqno ) );
993
+ // console.log( 'Extracted QIDs =>', qids );
994
+ // let maxQID = Math.max( 0, ...qids );
995
+ // console.log( 'maxQID =>', maxQID );
996
+
997
+ if ( section.maxQuestionNumber > 0 ) {
998
+ maxQID = section.maxQuestionNumber || 0;
999
+ }
975
1000
 
1001
+ // else {
1002
+ // maxQID = 0;
1003
+ // }
976
1004
  for ( let [ index1, questions ] of section.questions.entries() ) {
977
- if ( !questions.uniqueqno ) {
1005
+ if ( questions?.uniqueqno == null || questions.uniqueqno === 0 ) {
978
1006
  maxQID++;
979
1007
  section.questions[index1].uniqueqno = maxQID;
980
1008
  }
981
- if ( !questions.uniqueqid ) {
982
- section.questions[index1].uniqueqid =
983
- req.body.clientId +
984
- '-' +
985
- checkListDetails.checkListNumber +
986
- '-' +
987
- section.sectionNumber +
988
- '-' +
989
- maxQID;
1009
+ if ( questions?.uniqueqid == null || questions.uniqueqid === '' ) {
1010
+ section.questions[index1].uniqueqid = req.body.clientId + '-' + checkListDetails.checkListNumber + '-' + section.sectionNumber + '-' + maxQID;
990
1011
  }
991
1012
  }
992
1013
  }
993
1014
 
994
- console.log( 'else =>' );
995
1015
  for ( let [ index, question ] of section.questions.entries() ) {
996
1016
  await processNested( index, question );
997
1017
  }
@@ -1038,6 +1058,7 @@ export const update = async ( req, res ) => {
1038
1058
  question: section.questions,
1039
1059
  checkList: inputBody.checklistName,
1040
1060
  sectionNumber: section.sectionNumber,
1061
+ maxQuestionNumber: maxQID,
1041
1062
  } );
1042
1063
  }
1043
1064
  }