tango-app-api-store-builder 1.0.0-beta-169 → 1.0.0-beta-171

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-169",
3
+ "version": "1.0.0-beta-171",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2658,7 +2658,7 @@ export async function storeFixturesv2( req, res ) {
2658
2658
  planograms.map( async ( planogram ) => {
2659
2659
  const floors = await storeBuilderService.find(
2660
2660
  { planoId: planogram._id },
2661
- { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress:1, },
2661
+ { floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1 },
2662
2662
  );
2663
2663
 
2664
2664
  const floorsWithFixtures = await Promise.all(
@@ -4542,6 +4542,7 @@ export async function getRolloutDetails( req, res ) {
4542
4542
  $match: {
4543
4543
  clientId: req.body.clientId,
4544
4544
  storeId: { $in: storeDetails },
4545
+ planoProgress: 100,
4545
4546
  },
4546
4547
  },
4547
4548
  {
@@ -4611,8 +4612,8 @@ export async function getRolloutDetails( req, res ) {
4611
4612
  _id: '$planoType',
4612
4613
  type: { $first: '$planoType' },
4613
4614
  status: { $first: '$checklistStatus' },
4614
- taskId: { $last: '$_id' },
4615
- scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
4615
+ taskId: { $first: '$_id' },
4616
+ scheduleEndTime_iso: { $first: '$scheduleEndTime_iso' },
4616
4617
  },
4617
4618
  },
4618
4619
  {
@@ -4825,11 +4826,7 @@ export async function getRolloutDetails( req, res ) {
4825
4826
  },
4826
4827
  ];
4827
4828
 
4828
- let extraCondition = [ {
4829
- $match: {
4830
- planoProgress: 100,
4831
- },
4832
- } ];
4829
+ let extraCondition = [];
4833
4830
 
4834
4831
  if ( req.body?.filter?.type == 'rollout' ) {
4835
4832
  extraCondition.push( {
@@ -4896,22 +4893,32 @@ export async function getRolloutDetails( req, res ) {
4896
4893
  if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
4897
4894
  orCondition.push( {
4898
4895
  $expr: {
4899
- $eq: [ { $size: '$taskDetails' }, 0 ],
4896
+ $lt: [ { $size: '$taskDetails' }, 2 ],
4900
4897
  },
4901
- } );
4898
+ },
4899
+ {
4900
+ $and: [
4901
+ { taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
4902
+ { 'taskFeedback.fixtureStatus': 'disagree' },
4903
+ ],
4904
+ },
4905
+ {
4906
+ $and: [
4907
+ { taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
4908
+ { 'taskFeedback.vmStatus': 'disagree' },
4909
+ ],
4910
+ },
4911
+ );
4902
4912
  }
4903
4913
 
4904
4914
  if ( req.body.filter.status.includes( 'taskAssigned' ) ) {
4905
4915
  orCondition.push( {
4906
- $expr: {
4907
- $gt: [ { $size: '$taskDetails' }, 0 ],
4908
- },
4916
+ taskDetails: { $elemMatch: { status: { $ne: 'submit' }, breach: false } },
4909
4917
  } );
4910
4918
  }
4911
4919
 
4912
4920
  if ( req.body.filter.status.includes( 'reviewPending' ) ) {
4913
- orCondition.push( {
4914
- $or: [
4921
+ orCondition.push(
4915
4922
  {
4916
4923
  $and: [
4917
4924
  { taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
@@ -4924,8 +4931,7 @@ export async function getRolloutDetails( req, res ) {
4924
4931
  { 'taskFeedback.vmStatus': 'pending' },
4925
4932
  ],
4926
4933
  },
4927
- ],
4928
- } );
4934
+ );
4929
4935
  }
4930
4936
 
4931
4937
  if ( req.body.filter.status.includes( 'completed' ) ) {
@@ -4945,11 +4951,6 @@ export async function getRolloutDetails( req, res ) {
4945
4951
  extraCondition.push( { $match: { $or: orCondition } } );
4946
4952
  }
4947
4953
 
4948
- extraCondition.push(
4949
- { $skip: skip },
4950
- { $limit: limit },
4951
- );
4952
-
4953
4954
  if ( req.body.sortColumnName && req.body.sortBy ) {
4954
4955
  query.push(
4955
4956
  { $sort: { [req.body.sortColumnName]: req.body.sortBy } },
@@ -5025,31 +5026,8 @@ export async function getRolloutDetails( req, res ) {
5025
5026
  },
5026
5027
  { $count: 'count' },
5027
5028
  ],
5028
- doubleFloorStore: [
5029
- {
5030
- $group: {
5031
- _id: '$storeId',
5032
- count: { $sum: 1 },
5033
- },
5034
- },
5035
- {
5036
- $match: {
5037
- count: { $gt: 1 },
5038
- },
5039
- },
5040
- {
5041
- $group: {
5042
- _id: '',
5043
- doubleFloorList: { $addToSet: '$_id' },
5044
- },
5045
- },
5046
- {
5047
- $project: {
5048
- doubleFloorList: 1,
5049
- },
5050
- },
5051
- ],
5052
- data: extraCondition,
5029
+ data: [ ...extraCondition, { $skip: skip },
5030
+ { $limit: limit } ],
5053
5031
  count: [
5054
5032
  ...extraCondition,
5055
5033
  { $count: 'total' },
@@ -5058,7 +5036,37 @@ export async function getRolloutDetails( req, res ) {
5058
5036
  } );
5059
5037
 
5060
5038
 
5061
- let rolloutDetails = await storeBuilderService.aggregate( query );
5039
+ let floorQuery = [
5040
+ {
5041
+ $match: {
5042
+ clientId: req.body.clientId,
5043
+ storeId: { $in: storeDetails },
5044
+ },
5045
+ },
5046
+ {
5047
+ $group: {
5048
+ _id: '$storeId',
5049
+ count: { $sum: 1 },
5050
+ },
5051
+ },
5052
+ {
5053
+ $match: {
5054
+ count: { $gt: 1 },
5055
+ },
5056
+ },
5057
+ {
5058
+ $group: {
5059
+ _id: '',
5060
+ storeList: { $addToSet: '$_id' },
5061
+ },
5062
+ },
5063
+ ];
5064
+
5065
+
5066
+ let [ rolloutDetails, doubleFloorList ] = await Promise.all( [
5067
+ storeBuilderService.aggregate( query ),
5068
+ storeBuilderService.aggregate( floorQuery ),
5069
+ ] );
5062
5070
  let result = {
5063
5071
  cardData: {
5064
5072
  totalStore: rolloutDetails?.[0]?.totalStore?.[0]?.count || 0,
@@ -5067,7 +5075,7 @@ export async function getRolloutDetails( req, res ) {
5067
5075
  vmPendingStore: rolloutDetails?.[0]?.vmPending?.[0]?.count || 0,
5068
5076
  flagStore: rolloutDetails?.[0]?.flag?.[0]?.count || 0,
5069
5077
  flagStore: rolloutDetails?.[0]?.flag?.[0]?.count || 0,
5070
- doubleFloorStore: rolloutDetails?.[0]?.doubleFloorStore?.[0]?.doubleFloorList || [],
5078
+ doubleFloorStore: doubleFloorList[0]?.storeList|| [],
5071
5079
  },
5072
5080
  tableData: {
5073
5081
  count: rolloutDetails?.[0]?.count?.[0]?.total || 0,
@@ -662,6 +662,7 @@ export async function updateAnswersv2( req, res ) {
662
662
  taskType: req.body.taskType,
663
663
  storeName: req.body?.storeName,
664
664
  storeId: req.body?.storeId,
665
+ date_string: dayjs().format( 'YYYY-MM-DD' ),
665
666
  };
666
667
  console.log( '111111', data.answers[0] );
667
668
  console.log( '111111', data.answers[0].issues[0] );
@@ -1053,7 +1054,7 @@ export async function revokeTask( req, res ) {
1053
1054
  if ( !req.body.floorId ) {
1054
1055
  return res.sendError( 'floor id is required', 400 );
1055
1056
  }
1056
- await processedService.deleteMany( { planoId: req.body.planoId, floorId: req.body.floorId, checklistStatus: { $ne: 'submit' }, date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
1057
+ await processedService.deleteMany( { planoId: req.body.planoId, floorId: req.body.floorId, checklistStatus: { $ne: 'submit' }, ...( req.body?.type && { planoType: req.body?.type } ) } );
1057
1058
  return res.sendSuccess( 'Task revoked successfully' );
1058
1059
  } catch ( e ) {
1059
1060
  logger.error( { functionName: 'revokeTask', error: e } );