tango-app-api-trax 3.3.1-beta-44 → 3.3.1-beta-46

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.3.1-beta-44",
3
+ "version": "3.3.1-beta-46",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -543,17 +543,13 @@ export const flagCardsV1 = async ( req, res ) => {
543
543
  let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
544
544
  let getUserEmails = await getChecklistUsers( loginUser );
545
545
  // End: Get User Based Checklist////
546
-
547
546
  const findQuery = [
548
547
  {
549
548
  $match: {
550
549
  client_id: clientId,
551
- $or: [
552
- { store_id: { $in: storeId } },
553
- { aiStoreList: { $in: storeId } },
554
- ],
550
+ // $or: [ { store_id: { $in: storeId } }, { aiStoreList: { $in: storeId } } ],
555
551
  date_iso: { $gte: adjustedFromDate, $lte: adjustedToDate },
556
- $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
552
+ $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } }, { aiStoreList: { $in: storeId } } ],
557
553
  },
558
554
  },
559
555
  {
@@ -690,12 +686,9 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
690
686
  // End: Get User Based Checklist////
691
687
  const createFindQuery = ( fromDate, toDate ) => [
692
688
  { $match: { client_id: requestData.clientId,
693
- $or: [
694
- { store_id: { $in: requestData.storeId } },
695
- { aiStoreList: { $in: requestData.storeId } },
696
- ],
689
+ // $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ],
697
690
  date_iso: { $gte: fromDate, $lte: toDate },
698
- $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
691
+ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } }, { aiStoreList: { $in: requestData.storeId } } ],
699
692
  } },
700
693
  {
701
694
  $project: {
@@ -720,12 +713,8 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
720
713
  let comparisonData = Math.abs( ( ( rangeOneVal - rangeTwoVal ) / rangeTwoVal ) * 100 );
721
714
  if ( comparisonData === Infinity ) comparisonData = 0;
722
715
  comparisonData = comparisonData % 1 === 0 ? comparisonData.toFixed( 0 ) : comparisonData.toFixed( 1 );
723
-
724
716
  comparisonData = parseInt( comparisonData );
725
-
726
-
727
717
  const ComparisonFlag = rangeOneVal > rangeTwoVal;
728
-
729
718
  return { comparisonData, ComparisonFlag };
730
719
  };
731
720
 
@@ -737,13 +726,10 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
737
726
  clientId: requestData.clientId,
738
727
  };
739
728
 
740
- console.log( dayjs( fromDate ).format( 'YYYY-MM-DD' ), 'from date' );
741
-
742
- console.log( dayjs( toDate ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'current' );
743
-
744
- console.log( dayjs( toDate ).format( 'YYYY-MM-DD' ), 'previous' );
745
-
746
- console.log( dayjs( toDate ).startOf( 'day' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'new start of' );
729
+ // console.log( dayjs( fromDate ).format( 'YYYY-MM-DD' ), 'from date' );
730
+ // console.log( dayjs( toDate ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'current' );
731
+ // console.log( dayjs( toDate ).format( 'YYYY-MM-DD' ), 'previous' );
732
+ // console.log( dayjs( toDate ).startOf( 'day' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'new start of' );
747
733
 
748
734
  const publishedAiChecklists = await checklistconfigService.find(
749
735
  {
@@ -759,9 +745,7 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
759
745
 
760
746
  const LamdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
761
747
  const resultData = await LamdaServiceCall( LamdaURL, detectionPayload );
762
-
763
748
  const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
764
-
765
749
  if ( resultData?.status_code === '200' ) {
766
750
  let result = 0;
767
751
  published.forEach( ( item ) => {
@@ -821,10 +805,9 @@ export const flagTablesV1 = async ( req, res ) => {
821
805
  let findAndQuery = [];
822
806
  findAndQuery.push(
823
807
  { client_id: requestData.clientId },
824
- { $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
825
- { date_iso: { $gte: fromDate } },
826
- { date_iso: { $lte: toDate } },
827
- { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
808
+ // { $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
809
+ { date_iso: { $gte: fromDate, $lte: toDate } },
810
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } }, { aiStoreList: { $in: requestData.storeId } } ] },
828
811
  );
829
812
 
830
813
  if ( requestData?.filter === 'all' ) {
@@ -1881,7 +1864,7 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
1881
1864
  { date_iso: { $lte: dayjs.utc( reqestData.toDate ).endOf( 'day' ).toDate() } },
1882
1865
  { sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.sourceCheckList_id ) },
1883
1866
  // { store_id: { $in: reqestData?.storeId } },
1884
- { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
1867
+ { $or: [ { store_id: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
1885
1868
  ],
1886
1869
  },
1887
1870
  },
@@ -2187,10 +2170,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2187
2170
  { date_iso: { $lte: rangeTwoToDate } },
2188
2171
  { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
2189
2172
  // { store_id: { $in: requestData?.storeId } },
2190
- { '$or': [
2191
- { '$and': findORQuery1 },
2192
- { '$and': findORQuery2 },
2193
- ] },
2173
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
2194
2174
  ],
2195
2175
  },
2196
2176
  },
@@ -2304,10 +2284,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2304
2284
  client_id: requestData.clientId,
2305
2285
  sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
2306
2286
  // store_id: { $in: requestData.storeId },
2307
- $or: [
2308
- { '$and': findORQuery1 },
2309
- { '$and': findORQuery2 },
2310
- ],
2287
+ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
2311
2288
  },
2312
2289
  },
2313
2290
  {
@@ -2333,10 +2310,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2333
2310
  client_id: requestData.clientId,
2334
2311
  sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ),
2335
2312
  // store_id: { $in: requestData.storeId },
2336
- $or: [
2337
- { '$and': findORQuery1 },
2338
- { '$and': findORQuery2 },
2339
- ],
2313
+ $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ],
2340
2314
  },
2341
2315
  },
2342
2316
  {
@@ -2380,7 +2354,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2380
2354
  try {
2381
2355
  let reqestData = req.body;
2382
2356
  // Get User Based Checklist //
2383
- let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
2357
+ let loginUser = { clientId: reqestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
2384
2358
  let getUserEmails = await getChecklistUsers( loginUser );
2385
2359
  // End: Get User Based Checklist////
2386
2360
  if ( reqestData.ChecklistType == 'custom' ) {
@@ -2398,7 +2372,7 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2398
2372
  // ],
2399
2373
  // },
2400
2374
  // { store_id: { $in: reqestData?.storeId } },
2401
- { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
2375
+ { $or: [ { store_id: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: getUserEmails } } ] },
2402
2376
  ],
2403
2377
  },
2404
2378
  };
@@ -2659,12 +2633,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
2659
2633
  let findQuery = [
2660
2634
  { $match: { $and: [
2661
2635
  { client_id: requestData.clientId },
2662
- {
2663
- $or: [
2664
- { store_id: { $in: requestData.storeId } },
2665
- { aiStoreList: { $in: requestData.storeId } },
2666
- ],
2667
- },
2636
+ { $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
2668
2637
  { date_iso: { $gte: fromDate } },
2669
2638
  { date_iso: { $lte: toDate } },
2670
2639
  {