tango-app-api-trax 3.3.1-beta-10 → 3.3.1-beta-12

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;
@@ -2995,108 +2995,6 @@ export const selectAssign = async ( req, res ) => {
2995
2995
  }
2996
2996
  };
2997
2997
 
2998
- export const checklistV2 = async ( req, res ) => {
2999
- try {
3000
- let limit = parseInt( req.query.limit ) || 10;
3001
- let offset = parseInt( req.query.offset - 1 ) || 0;
3002
- let page = offset * limit;
3003
- let query = [];
3004
- query.push(
3005
- {
3006
- $match: {
3007
- type: 'checklist',
3008
- client_id: req.query.clientId,
3009
- isdeleted: false,
3010
- ...( req.user.userType == 'client' && req.user.role != 'superadmin' ) ? { 'owner.value': { $in: [ req.user.email ] } } : {},
3011
- },
3012
- },
3013
- );
3014
-
3015
- if ( req.query.search && req.query.search != '' ) {
3016
- req.query.search = req.query.search.replace( /([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1' );
3017
- query.push( {
3018
- $match: {
3019
- checkListName: { $regex: new RegExp( req.query.search, 'i' ) },
3020
- },
3021
- } );
3022
- }
3023
-
3024
- query.push(
3025
- {
3026
- $project: {
3027
- checkList: { $toLower: '$checkListName' },
3028
- checkListName: 1,
3029
- coverage: 1,
3030
- createdBy: 1,
3031
- userName: { $toLower: '$createdByName' },
3032
- createdByName: 1,
3033
- storeCount: 1,
3034
- createdAt: 1,
3035
- publish: 1,
3036
- checkListType: 1,
3037
- questionCount: 1,
3038
- checkListChar: { $substr: [ '$checkListName', 0, 2 ] },
3039
- },
3040
- },
3041
- );
3042
-
3043
- if ( req.query.sortColumnName && req.query.sortColumnName != '' && req.query.sortBy != '' ) {
3044
- if ( req.query.sortColumnName == 'status' ) {
3045
- req.query.sortColumnName = 'publish';
3046
- }
3047
- if ( req.query.sortColumnName != 'publish' ) {
3048
- query.push( {
3049
- $addFields: { lowerName: { $toLower: `$${req.query.sortColumnName}` } },
3050
- } );
3051
- query.push( {
3052
- $sort: { lowerName: parseInt( req.query.sortBy ) },
3053
- } );
3054
- } else {
3055
- query.push( {
3056
- $sort: { publish: parseInt( req.query.sortBy ) },
3057
- } );
3058
- }
3059
- } else {
3060
- query.push(
3061
- { $sort: { createdAt: -1 } },
3062
- );
3063
- }
3064
-
3065
- query.push( {
3066
- $facet: {
3067
- data: [
3068
- { $skip: page },
3069
- { $limit: limit },
3070
- ],
3071
- count: [
3072
- { $count: 'totalCount' },
3073
- ],
3074
- },
3075
- } );
3076
-
3077
- let checkList = await checklistService.aggregate( query );
3078
-
3079
- if ( !checkList[0].data.length ) {
3080
- return res.sendError( 'no data found', 204 );
3081
- }
3082
-
3083
- checkList[0].data.forEach( ( item ) => {
3084
- if ( item.storeCount > 0 && item.storeCount <= 9 ) {
3085
- item.storeCount = '0' + item.storeCount;
3086
- }
3087
- if ( item.questionCount > 0 && item.questionCount <= 9 ) {
3088
- item.questionCount = '0' + item.questionCount;
3089
- }
3090
- item.createdAt = dayjs( item.createdAt ).format( 'DD MMM, YYYY' );
3091
- } );
3092
-
3093
- return res.sendSuccess( { result: checkList[0].data, count: checkList[0].count[0].totalCount } );
3094
- } catch ( e ) {
3095
- logger.error( 'checklist V2 =>', e );
3096
- return res.sendError( e, 500 );
3097
- }
3098
- };
3099
-
3100
2998
  async function assignUsers( data ) {
3101
2999
  let assignedData;
3102
3000
  if ( data.coverage == 'store' ) {