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

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-159",
3
+ "version": "1.0.0-beta-160",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "path": "^0.12.7",
33
33
  "selenium-webdriver": "^4.31.0",
34
34
  "sharp": "^0.34.1",
35
- "tango-api-schema": "^2.2.192",
35
+ "tango-api-schema": "^2.2.201",
36
36
  "tango-app-api-middleware": "3.1.48",
37
37
  "url": "^0.11.4",
38
38
  "winston": "^3.17.0",
@@ -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: ['LKST98', 'LKST682', 'ST185', 'ST36', 'LKST1193'] } },
7403
+ // { storeName: { $in: [ 'LKST1324', 'LKST495' ] } },
7404
7404
  // { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
7405
7405
  ],
7406
7406
  };
@@ -1451,6 +1451,8 @@ export async function updateMissing( req, res ) {
1451
1451
 
1452
1452
  if ( !fixtureShelves.length ) return res.sendError( 'No shelves found for the fixture', 204 );
1453
1453
 
1454
+ console.log('called')
1455
+
1454
1456
  await Promise.all(
1455
1457
  fixtureShelves.map( async ( shelf ) => {
1456
1458
  const productMappings = await planoMappingService.find( { shelfId: shelf._id } );
@@ -1459,18 +1461,18 @@ export async function updateMissing( req, res ) {
1459
1461
  return { ...shelf.toObject(), products: [] };
1460
1462
  }
1461
1463
 
1462
- const productIds = productMappings.map( ( mapping ) => mapping.productId );
1463
- const products = await planoProductService.find( { _id: { $in: productIds } } );
1464
- const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
1464
+ // const productIds = productMappings.map( ( mapping ) => mapping.productId );
1465
+ // const products = await planoProductService.find( { _id: { $in: productIds } } );
1466
+ // const productMap = new Map( products.map( ( product ) => [ product._id.toString(), product.toObject() ] ) );
1465
1467
 
1466
1468
  const currentDate = new Date( dayjs().format( 'YYYY-MM-DD' ) );
1467
1469
 
1468
1470
  await Promise.all(
1469
1471
  productMappings.map( async ( mapping ) => {
1470
- const productData = productMap.get( mapping.productId.toString() );
1471
- if ( !productData ) {
1472
- return { ...mapping.toObject(), status: '' };
1473
- }
1472
+ // const productData = productMap.get( mapping?.productId?.toString() );
1473
+ // if ( !productData ) {
1474
+ // return { ...mapping.toObject(), status: '' };
1475
+ // }
1474
1476
 
1475
1477
  const mappingCompliance = await planoComplianceService.findOne( {
1476
1478
  planoMappingId: mapping._id,
@@ -1484,7 +1486,7 @@ export async function updateMissing( req, res ) {
1484
1486
 
1485
1487
  return {
1486
1488
  ...mapping.toObject(),
1487
- ...productData,
1489
+ // ...productData,
1488
1490
  };
1489
1491
  } ),
1490
1492
  );
@@ -4857,6 +4859,58 @@ export async function getRolloutDetails( req, res ) {
4857
4859
  } );
4858
4860
  }
4859
4861
 
4862
+ if ( req.body.filter.status.length ) {
4863
+ if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
4864
+ extraCondition.push( {
4865
+ $match: {
4866
+ $expr: {
4867
+ $eq: [ { $size: '$taskDetails' }, 0 ],
4868
+ },
4869
+ },
4870
+ } );
4871
+ }
4872
+ if ( req.body.filter.status.includes( 'taskAssigned' ) ) {
4873
+ extraCondition.push( {
4874
+ $match: {
4875
+ $expr: {
4876
+ $gt: [ { $size: '$taskDetails' }, 0 ],
4877
+ },
4878
+ },
4879
+ } );
4880
+ }
4881
+ if ( req.body.filter.status.includes( 'reviewPending' ) ) {
4882
+ extraCondition.push( {
4883
+ $match: {
4884
+ $or: [
4885
+ {
4886
+ compliance: { $elemMatch: { feedbackStatus: 'merchPending' } },
4887
+ },
4888
+ {
4889
+ compliance: { $elemMatch: { feedbackStatus: 'vmPending' } },
4890
+ },
4891
+ ],
4892
+ },
4893
+ } );
4894
+ }
4895
+ if ( req.body.filter.status.includes( 'completed' ) ) {
4896
+ extraCondition.push( {
4897
+ $match: {
4898
+ $and: [
4899
+ {
4900
+ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } },
4901
+ },
4902
+ {
4903
+ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } },
4904
+ },
4905
+ {
4906
+ $expr: { $eq: [ { $size: '$compliance' }, 0 ] },
4907
+ },
4908
+ ],
4909
+ },
4910
+ } );
4911
+ }
4912
+ }
4913
+
4860
4914
  extraCondition.push(
4861
4915
  { $skip: skip },
4862
4916
  { $limit: limit },
@@ -5020,6 +5074,7 @@ export async function getRolloutTaskDetails( req, res ) {
5020
5074
  taskId: { $last: '$_id' },
5021
5075
  redoStatus: { $last: '$redoStatus' },
5022
5076
  scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
5077
+ taskId: { $last: '$_id' },
5023
5078
  },
5024
5079
  },
5025
5080
  {
@@ -5033,6 +5088,7 @@ export async function getRolloutTaskDetails( req, res ) {
5033
5088
  floorId: '$_id.floorId',
5034
5089
  redoStatus: '$redoStatus',
5035
5090
  endTime: '$scheduleEndTime_iso',
5091
+ id: '$taskId',
5036
5092
  breach: {
5037
5093
  $cond: {
5038
5094
  if: {
@@ -5303,6 +5359,7 @@ export async function getRolloutTaskDetails( req, res ) {
5303
5359
  redoStatus: '$$task.redoStatus',
5304
5360
  endTime: '$$task.endTime',
5305
5361
  breach: '$$task.breach',
5362
+ taskId: '$$task.id',
5306
5363
  feedbackStatus: {
5307
5364
  $switch: {
5308
5365
  branches: [
@@ -5328,10 +5385,10 @@ export async function getRolloutTaskDetails( req, res ) {
5328
5385
 
5329
5386
  let taskInfo = await planotaskService.aggregate( query );
5330
5387
  const [ merchCount, vmCount ] = await Promise.all( [
5331
- await layoutService.count( { _id: req.query.floorId, isMerchEdited: true } ),
5332
- await layoutService.count( { _id: req.query.floorId, isVmEdited: true } ),
5388
+ await storeFixtureService.count( { floorId: req.query.floorId, isMerchEdited: true } ),
5389
+ await storeFixtureService.count( { floorId: req.query.floorId, isVmEdited: true } ),
5333
5390
  ] );
5334
- return res.sendSuccess( { taskDetails: taskInfo, merchCount, vmCount } );
5391
+ return res.sendSuccess( { taskDetails: taskInfo?.[0]?.taskStatus || [], merchCount, vmCount } );
5335
5392
  } catch ( e ) {
5336
5393
  logger.error( { functionName: 'getTaskDetails', error: e } );
5337
5394
  return res.sendError( e, 500 );
@@ -15,6 +15,7 @@ import * as floorService from '../service/storeBuilder.service.js';
15
15
  import * as planoStaticService from '../service/planoStaticData.service.js';
16
16
  import * as assignService from '../service/assignService.service.js';
17
17
  import * as storeBuilderService from '../service/storeBuilder.service.js';
18
+ import * as commentsService from '../service/planoGlobalComment.service.js';
18
19
 
19
20
 
20
21
  dayjs.extend( timeZone );
@@ -1031,7 +1032,11 @@ export async function redoTask( req, res ) {
1031
1032
 
1032
1033
  export async function revokeTask( req, res ) {
1033
1034
  try {
1034
- await processedService.deleteMany( { checklistName: req.body.checkListName, date_string: dayjs().format( 'YYYY-MM-DD' ), planoId: req.body.planoId, floorId: req.body.floorId } );
1035
+ if(!req.body.taskId) {
1036
+ return res.sendError('Checklist type is required',400)
1037
+ }
1038
+ await processedService.deleteMany( { _id:req.body.taskId } );
1039
+ return res.sendSuccess('Task revoked successfully');
1035
1040
  } catch ( e ) {
1036
1041
  logger.error( { functionName: 'revokeTask', error: e } );
1037
1042
  return res.sendError( e, 500 );
@@ -16,4 +16,5 @@ storeBuilderTaskRouter
16
16
  .get( '/getVmDetails', isAllowedSessionHandler, taskController.getVmDetails )
17
17
  .post( '/generateTaskExcel', taskController.generatetaskDetails )
18
18
  .post( '/getSubmitDetails', taskController.taskSubmitDetails )
19
- .post( '/redoTask', isAllowedSessionHandler, taskController.redoTask );
19
+ .post( '/redoTask', isAllowedSessionHandler, taskController.redoTask )
20
+ .post( '/revokeTask', isAllowedSessionHandler, taskController.revokeTask );
@@ -60,3 +60,7 @@ export async function upsertOne( query, record ) {
60
60
  export async function removeKeys( query, data ) {
61
61
  return model.storeFixtureModel.updateOne( query, data );
62
62
  }
63
+
64
+ export async function count( query ) {
65
+ return model.storeFixtureModel.countDocuments( query );
66
+ }