tango-app-api-store-builder 1.0.0-beta-158 → 1.0.0-beta-159

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-store-builder",
3
- "version": "1.0.0-beta-158",
3
+ "version": "1.0.0-beta-159",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -178,6 +178,7 @@ export async function duplicateTemplate( req, res ) {
178
178
  templateDetails = templateDetails.toObject();
179
179
  delete templateDetails._id;
180
180
  templateDetails.fixtureName = newFixtureName;
181
+ templateDetails.status = 'draft';
181
182
  let duplicateDetails = await fixtureConfigService.create( templateDetails );
182
183
  return res.sendSuccess( { message: 'Fixture template duplicated successfully', id: duplicateDetails._id } );
183
184
  } catch ( e ) {
@@ -307,7 +307,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
307
307
  pipeline.push( { $sort: { _id: -1 } } );
308
308
  }
309
309
 
310
-
310
+ console.log( pipeline );
311
311
  return pipeline;
312
312
  }
313
313
 
@@ -890,5 +890,60 @@ export async function getPlanoRevisionById( req, res ) {
890
890
  res.sendError( 'Failed to fetch plano revision', 500 );
891
891
  }
892
892
  }
893
+ export async function getRolloutFeedback( req, res ) {
894
+ try {
895
+ const taskTypes = req.body.filterByTask && req.body.filterByTask.length > 0 ? req.body.filterByTask : [ 'merchRollout', 'vmRollout' ];
896
+ const filterByStatus = req.body.filterByStatus || [];
897
+ const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
898
+ const resultMap = {};
899
+ const commentMap = {};
900
+ await Promise.all(
901
+ taskTypes.map( async ( type, index ) => {
902
+ console.log( type );
903
+ const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
904
+
905
+ let data = await planoTaskService.aggregate( pipeline );
906
+ console.log( data );
907
+ if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
908
+ console.log( '-------------1', filterByApprovalStatus );
909
+ data.forEach( ( element ) => {
910
+ element.answers?.forEach( ( ans ) => {
911
+ ans.issues = ans.issues?.filter(
912
+ ( issue ) => issue.Details && issue.Details.length > 0,
913
+ );
914
+ } );
915
+ element.answers = element.answers?.filter(
916
+ ( ans ) => ans.issues && ans.issues.length > 0,
917
+ );
918
+ } );
919
+ data = data.filter(
920
+ ( element ) => element.answers && element.answers.length > 0,
921
+ );
922
+ }
923
+
924
+
925
+ resultMap[type] = data;
926
+
927
+ const comments = await planoGlobalCommentService.find( {
928
+ planoId: new mongoose.Types.ObjectId( req.body.planoId ),
929
+ floorId: new mongoose.Types.ObjectId( req.body.floorId ),
930
+ taskType: type,
931
+ } );
932
+ commentMap[type] = comments;
933
+ } ),
934
+ );
935
+ const response = {
936
+ merchRolloutData: resultMap['merchRollout'] || [],
937
+ vmRolloutData: resultMap['vmRollout'] || [],
938
+ merchRolloutComment: commentMap['merchRollout'] || [],
939
+ vmRolloutComment: commentMap['vmRollout'] || [],
940
+ };
941
+
942
+ res.sendSuccess( response );
943
+ } catch ( e ) {
944
+ logger.error( { functionName: 'getRolloutFeedback', error: e } );
945
+ return res.sendError( e, 500 );
946
+ }
947
+ }
893
948
 
894
949
 
@@ -123,24 +123,6 @@ async function getMaxFixtureLibCode() {
123
123
  export async function createFixture( req, res ) {
124
124
  try {
125
125
  let FixLibCode = await getMaxFixtureLibCode();
126
- let query = [
127
- {
128
- $addFields: {
129
- fixtureCategoryLower: { $toLower: '$fixtureCategory' },
130
- },
131
- },
132
- {
133
- $match: {
134
- 'clientId': req.body.clientId,
135
- 'fixtureCategoryLower': req.body.fixtureCategory.toLowerCase(),
136
- 'fixtureWidth.value': 10,
137
- },
138
- },
139
- ];
140
- let fixLibDetails = await planoLibraryService.aggregate( query );
141
- if ( fixLibDetails.length ) {
142
- return res.sendError( `Fixture Name ${req.body.fixtureCategory} already Exists`, 400 );
143
- }
144
126
  let data ={
145
127
  clientId: req.body.clientId,
146
128
  fixtureCategory: req.body.fixtureCategory,
@@ -184,7 +166,7 @@ export async function updateFixture( req, res ) {
184
166
  'clientId': req.body.clientId,
185
167
  'fixtureCategoryLower': req.body.fixtureCategory.toLowerCase(),
186
168
  'fixtureWidth.value': req.body.fixtureWidth.value,
187
- '_id': { $ne: req.params.fixtureId },
169
+ '_id': { $ne: new ObjectId( req.params.fixtureId ) },
188
170
  },
189
171
  },
190
172
  ];
@@ -200,7 +182,6 @@ export async function updateFixture( req, res ) {
200
182
  await planoLibraryService.updateOne( { _id: req.params.fixtureId }, fixtureData );
201
183
  return res.sendSuccess( 'Fixture library details updated successfully' );
202
184
  } catch ( e ) {
203
- console.log( e );
204
185
  logger.error( { functionName: 'updateFixture', error: e } );
205
186
  return res.sendError( e, 500 );
206
187
  }
@@ -541,6 +522,7 @@ export async function duplicateFixture( req, res ) {
541
522
  fixtureLibDetails.fixtureCategory = newFixName;
542
523
  let FixLibCode = await getMaxFixtureLibCode();
543
524
  fixtureLibDetails.fixtureLibCode = FixLibCode;
525
+ fixtureLibDetails.status = 'draft';
544
526
  let duplicateData = await planoLibraryService.create( fixtureLibDetails );
545
527
  return res.sendSuccess( { message: 'Fixture duplicated successfully', id: duplicateData._id } );
546
528
  } catch ( e ) {
@@ -1252,6 +1234,7 @@ export async function duplicateVmLib( req, res ) {
1252
1234
  }
1253
1235
  }
1254
1236
  vmDetails.vmName = newVMName;
1237
+ vmDetails.status = 'draft';
1255
1238
  vmDetails.vmLibCode = await getMaxVMLibCode();
1256
1239
  let duplicateData = await vmService.create( vmDetails );
1257
1240
  return res.sendSuccess( { message: 'VM duplicated successfully', id: duplicateData._id } );
@@ -7400,7 +7400,7 @@ export async function migrateCrestv1( req, res ) {
7400
7400
  clientId: '11',
7401
7401
  $and: [
7402
7402
  { storeName: req.body.storeName },
7403
- // { storeName: { $in: [ 'LKST1324', 'LKST495' ] } },
7403
+ // { storeName: { $in: ['LKST98', 'LKST682', 'ST185', 'ST36', 'LKST1193'] } },
7404
7404
  // { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
7405
7405
  ],
7406
7406
  };
@@ -7430,15 +7430,15 @@ export async function migrateCrestv1( req, res ) {
7430
7430
 
7431
7431
  const existingPlanogram = await planoService.findOne( { storeName: storeData.storeName } );
7432
7432
 
7433
- // if ( existingPlanogram ) {
7434
- // const checkTaskSubmitted = await planoTaskService.findOne( { planoId: existingPlanogram.toObject()._id } );
7433
+ if ( existingPlanogram ) {
7434
+ const checkTaskSubmitted = await planoTaskService.findOne( { planoId: existingPlanogram.toObject()._id } );
7435
7435
 
7436
- // const checkTaskCreated = await processedTaskService.findOne( { storeName: storeData.storeName, date_string: dayjs().format( 'YYYY-MM-DD' ), isPlano: true } );
7436
+ const checkTaskCreated = await processedTaskService.findOne( { storeName: storeData.storeName, date_string: dayjs().format( 'YYYY-MM-DD' ), isPlano: true } );
7437
7437
 
7438
- // if ( checkTaskSubmitted || checkTaskCreated ) {
7439
- // continue;
7440
- // }
7441
- // }
7438
+ if ( checkTaskSubmitted || checkTaskCreated ) {
7439
+ continue;
7440
+ }
7441
+ }
7442
7442
 
7443
7443
 
7444
7444
  if ( existingPlanogram?.toObject()?._id && mongoose.Types.ObjectId.isValid( existingPlanogram?.toObject()?._id ) ) {