tango-app-api-trax 3.3.1-beta-11 → 3.3.1-beta-13

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.
@@ -56,6 +56,7 @@ export const checklist = async ( req, res ) => {
56
56
  $project: {
57
57
  checkList: { $toLower: '$checkListName' },
58
58
  checkListName: 1,
59
+ coverage: 1,
59
60
  createdBy: 1,
60
61
  userName: { $toLower: '$createdByName' },
61
62
  createdByName: 1,
@@ -126,7 +127,6 @@ export const checklist = async ( req, res ) => {
126
127
  }
127
128
  };
128
129
 
129
-
130
130
  export const create = async ( req, res ) => {
131
131
  try {
132
132
  let inputBody = req.body;
@@ -3022,108 +3022,6 @@ export const selectAssign = async ( req, res ) => {
3022
3022
  }
3023
3023
  };
3024
3024
 
3025
- export const checklistV2 = async ( req, res ) => {
3026
- try {
3027
- let limit = parseInt( req.query.limit ) || 10;
3028
- let offset = parseInt( req.query.offset - 1 ) || 0;
3029
- let page = offset * limit;
3030
- let query = [];
3031
- query.push(
3032
- {
3033
- $match: {
3034
- type: 'checklist',
3035
- client_id: req.query.clientId,
3036
- isdeleted: false,
3037
- ...( req.user.userType == 'client' && req.user.role != 'superadmin' ) ? { 'owner.value': { $in: [ req.user.email ] } } : {},
3038
- },
3039
- },
3040
- );
3041
-
3042
- if ( req.query.search && req.query.search != '' ) {
3043
- req.query.search = req.query.search.replace( /([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1' );
3044
- query.push( {
3045
- $match: {
3046
- checkListName: { $regex: new RegExp( req.query.search, 'i' ) },
3047
- },
3048
- } );
3049
- }
3050
-
3051
- query.push(
3052
- {
3053
- $project: {
3054
- checkList: { $toLower: '$checkListName' },
3055
- checkListName: 1,
3056
- coverage: 1,
3057
- createdBy: 1,
3058
- userName: { $toLower: '$createdByName' },
3059
- createdByName: 1,
3060
- storeCount: 1,
3061
- createdAt: 1,
3062
- publish: 1,
3063
- checkListType: 1,
3064
- questionCount: 1,
3065
- checkListChar: { $substr: [ '$checkListName', 0, 2 ] },
3066
- },
3067
- },
3068
- );
3069
-
3070
- if ( req.query.sortColumnName && req.query.sortColumnName != '' && req.query.sortBy != '' ) {
3071
- if ( req.query.sortColumnName == 'status' ) {
3072
- req.query.sortColumnName = 'publish';
3073
- }
3074
- if ( req.query.sortColumnName != 'publish' ) {
3075
- query.push( {
3076
- $addFields: { lowerName: { $toLower: `$${req.query.sortColumnName}` } },
3077
- } );
3078
- query.push( {
3079
- $sort: { lowerName: parseInt( req.query.sortBy ) },
3080
- } );
3081
- } else {
3082
- query.push( {
3083
- $sort: { publish: parseInt( req.query.sortBy ) },
3084
- } );
3085
- }
3086
- } else {
3087
- query.push(
3088
- { $sort: { createdAt: -1 } },
3089
- );
3090
- }
3091
-
3092
- query.push( {
3093
- $facet: {
3094
- data: [
3095
- { $skip: page },
3096
- { $limit: limit },
3097
- ],
3098
- count: [
3099
- { $count: 'totalCount' },
3100
- ],
3101
- },
3102
- } );
3103
-
3104
- let checkList = await checklistService.aggregate( query );
3105
-
3106
- if ( !checkList[0].data.length ) {
3107
- return res.sendError( 'no data found', 204 );
3108
- }
3109
-
3110
- checkList[0].data.forEach( ( item ) => {
3111
- if ( item.storeCount > 0 && item.storeCount <= 9 ) {
3112
- item.storeCount = '0' + item.storeCount;
3113
- }
3114
- if ( item.questionCount > 0 && item.questionCount <= 9 ) {
3115
- item.questionCount = '0' + item.questionCount;
3116
- }
3117
- item.createdAt = dayjs( item.createdAt ).format( 'DD MMM, YYYY' );
3118
- } );
3119
-
3120
- return res.sendSuccess( { result: checkList[0].data, count: checkList[0].count[0].totalCount } );
3121
- } catch ( e ) {
3122
- logger.error( 'checklist V2 =>', e );
3123
- return res.sendError( e, 500 );
3124
- }
3125
- };
3126
-
3127
3025
  async function assignUsers( data ) {
3128
3026
  let assignedData;
3129
3027
  if ( data.coverage == 'store' ) {