tango-app-api-infra 3.9.12 → 3.9.14

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-infra",
3
- "version": "3.9.12",
3
+ "version": "3.9.14",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2603,7 +2603,7 @@ export async function ticketList( req, res ) {
2603
2603
  requestedSortType = 'approve';
2604
2604
  } else if ( inputData.sortBy === 'status' ) {
2605
2605
  sortKey = 'status';
2606
- requestedSortType =( req.user.userType === 'tango' && inputData.tangoType === 'store' )? 'tangorevirew' : inputData?.permissionType === 'review' ? 'review' : ( ticketsFeature && !ticketsApproveFeature )? 'review':'approve';
2606
+ requestedSortType =( req.user.userType === 'tango' && inputData.tangoType === 'store' )? 'tangoreview' : inputData?.permissionType === 'review' ? 'review' : ( ticketsFeature && !ticketsApproveFeature )? 'review':'approve';
2607
2607
  } else if ( inputData.sortBy === 'comments' ) {
2608
2608
  sortKey = 'comments';
2609
2609
  requestedSortType = 'finalRevision';
@@ -2615,16 +2615,7 @@ export async function ticketList( req, res ) {
2615
2615
  { [sortField]: { order: sortOrder } },
2616
2616
  ];
2617
2617
  }
2618
- // else if ( inputData.sortBy === 'status' ) {
2619
- // sortKey = 'status';
2620
- // requestedSortType = inputData?.permissionType === 'review' ? 'review' : 'approve';
2621
- // } else if ( inputData.sortBy === 'status' ) {
2622
- // sortKey = 'status';
2623
- // requestedSortType = inputData?.permissionType === 'review' ? 'review' : 'approve';
2624
- // } else if ( inputData.sortBy === 'status' ) {
2625
- // sortKey = 'status';
2626
- // requestedSortType = inputData?.permissionType === 'review' ? 'review' : 'approve';
2627
- // }
2618
+
2628
2619
 
2629
2620
  if ( requestedSortType ) {
2630
2621
  // const fallbackField = 'createdAt';
@@ -2727,48 +2718,84 @@ export async function ticketList( req, res ) {
2727
2718
  },
2728
2719
  ];
2729
2720
  break;
2721
+ // case 'revicedPerc':
2722
+ // searchQuery.sort = [
2723
+ // {
2724
+ // _script: {
2725
+ // type: 'string',
2726
+ // script: {
2727
+ // lang: 'painless',
2728
+ // source: `
2729
+ // try {
2730
+ // if (params._source != null && params._source.mappingInfo != null) {
2731
+ // String found = null;
2732
+
2733
+ // for (def item : params._source.mappingInfo) {
2734
+ // if (item != null && item.type == params.miType && item.revicedPerc != null) {
2735
+ // String value = item.revicedPerc.toString();
2736
+
2737
+ // if (found == null || value.compareTo(found) > 0) {
2738
+ // found = value;
2739
+ // }
2740
+ // }
2741
+ // }
2742
+
2743
+ // if (found != null) {
2744
+ // return found;
2745
+ // }
2746
+ // }
2747
+ // } catch (Exception e) {
2748
+ // // ignore and fallback
2749
+ // }
2750
+
2751
+ // // fallback to root-level revicedPerc
2752
+ // if (params._source != null && params._source.revicedPerc != null) {
2753
+ // return params._source.revicedPerc.toString();
2754
+ // }
2755
+
2756
+ // return "";
2757
+ // `,
2758
+ // params: {
2759
+ // miType: requestedSortType,
2760
+ // },
2761
+ // },
2762
+ // order: sortOrder,
2763
+ // },
2764
+ // },
2765
+ // ];
2766
+ // break;
2730
2767
  case 'revicedPerc':
2731
2768
  searchQuery.sort = [
2732
2769
  {
2733
2770
  _script: {
2734
- type: 'string',
2771
+ type: 'number',
2772
+ order: sortOrder,
2735
2773
  script: {
2736
2774
  lang: 'painless',
2737
2775
  source: `
2738
- try {
2739
- if (params._source != null && params._source.mappingInfo != null) {
2740
- String found = null;
2741
-
2742
- for (def item : params._source.mappingInfo) {
2743
- if (item != null && item.type == params.miType && item.revicedPerc != null) {
2744
- String value = item.revicedPerc.toString();
2745
-
2746
- if (found == null || value.compareTo(found) > 0) {
2747
- found = value;
2748
- }
2749
- }
2750
- }
2751
-
2752
- if (found != null) {
2753
- return found;
2754
- }
2755
- }
2756
- } catch (Exception e) {
2757
- // ignore and fallback
2758
- }
2759
-
2760
- // fallback to root-level revicedPerc
2761
- if (params._source != null && params._source.revicedPerc != null) {
2762
- return params._source.revicedPerc.toString();
2763
- }
2776
+ try {
2777
+ if (params._source != null && params._source.mappingInfo != null) {
2778
+ for (def item : params._source.mappingInfo) {
2779
+ if (item != null &&
2780
+ item.type == params.miType &&
2781
+ item.revicedPerc != null) {
2782
+
2783
+ String p = item.revicedPerc.toString().replace('%', '').trim();
2784
+ if (p.length() > 0) {
2785
+ return Double.parseDouble(p);
2786
+ }
2787
+ }
2788
+ }
2789
+ }
2790
+ } catch (Exception e) {}
2764
2791
 
2765
- return "";
2766
- `,
2792
+ // IMPORTANT: return null-equivalent for missing types
2793
+ return -1;
2794
+ `,
2767
2795
  params: {
2768
2796
  miType: requestedSortType,
2769
2797
  },
2770
2798
  },
2771
- order: sortOrder,
2772
2799
  },
2773
2800
  },
2774
2801
  ];
@@ -3867,30 +3894,10 @@ export async function ticketList( req, res ) {
3867
3894
  'Ticket ID': item?.ticketId,
3868
3895
  'Store Name': item?.storeName,
3869
3896
  'Store ID': item?.storeId,
3870
- 'Ticket Raised': item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.createdAt ? dayjs( item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.createdAt ).format( 'DD MMM, YYYY' ) : '',
3897
+ 'Ticket Raised': item?.createdAt ? dayjs( item?.createdAt ).format( 'DD MMM, YYYY' ) : '',
3871
3898
  'Issue Date': item?.dateString ? dayjs( item.dateString ).format( 'DD MMM, YYYY' ) : '',
3872
3899
  'Ticket Type': item?.type,
3873
3900
  'Actual FF': item?.footfallCount,
3874
-
3875
- 'Due Date (Formatted)': ( () => {
3876
- if ( Array.isArray( item?.mappingInfo ) ) {
3877
- // Find last mappingInfo whose type is NOT 'finalRevison'
3878
- const filtered = item.mappingInfo.filter(
3879
- ( f ) => f.dueDate && f.type !== 'finalRevison',
3880
- );
3881
- if ( filtered.length > 0 ) {
3882
- const lastDueDate = filtered[filtered.length - 1].dueDate;
3883
- if ( lastDueDate ) {
3884
- if ( dayjs( lastDueDate ).isSame( dayjs(), 'day' ) ) {
3885
- return 'Due Today';
3886
- }
3887
- return dayjs( lastDueDate ).format( 'DD MMM, YYYY' );
3888
- }
3889
- }
3890
- }
3891
- return '';
3892
- } )(),
3893
-
3894
3901
  'Store (Accuracy%)': item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.revicedPerc || '--',
3895
3902
  'Reviewer (Accuracy%)': item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.revicedPerc || '--',
3896
3903
  'Approver (Accuracy%)': item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.revicedPerc || '--',
@@ -3908,16 +3915,9 @@ export async function ticketList( req, res ) {
3908
3915
  ticketId: item?.ticketId,
3909
3916
  storeId: item?.storeId,
3910
3917
  storeName: item?.storeName,
3911
- ticketRaised: item?.type==='store'? item?.mappingInfo?.find( ( f ) => f?.type === 'tagging' )?.createdAt:item?.createdAt,
3918
+ ticketRaised: item?.createdAt,
3912
3919
  issueDate: item?.dateString,
3913
3920
  footfall: item?.footfallCount,
3914
- dueDate: ( () => {
3915
- if ( Array.isArray( item?.mappingInfo ) ) {
3916
- const filtered = item.mappingInfo.filter( ( f ) => f?.dueDate && f?.type !== 'finalRevisoon' );
3917
- return filtered.length > 0 ? filtered[filtered.length - 1].dueDate : '';
3918
- }
3919
- return '';
3920
- } )(),
3921
3921
  type: item?.type || 'store',
3922
3922
  storeRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.revicedPerc || '--',
3923
3923
  reviewerRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.revicedPerc || '--',