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

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-170",
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( {
@@ -4903,9 +4900,7 @@ export async function getRolloutDetails( req, res ) {
4903
4900
 
4904
4901
  if ( req.body.filter.status.includes( 'taskAssigned' ) ) {
4905
4902
  orCondition.push( {
4906
- $expr: {
4907
- $gt: [ { $size: '$taskDetails' }, 0 ],
4908
- },
4903
+ taskDetails: { $elemMatch: { status: { $ne: 'submit' }, breach: false } },
4909
4904
  } );
4910
4905
  }
4911
4906
 
@@ -4945,11 +4940,6 @@ export async function getRolloutDetails( req, res ) {
4945
4940
  extraCondition.push( { $match: { $or: orCondition } } );
4946
4941
  }
4947
4942
 
4948
- extraCondition.push(
4949
- { $skip: skip },
4950
- { $limit: limit },
4951
- );
4952
-
4953
4943
  if ( req.body.sortColumnName && req.body.sortBy ) {
4954
4944
  query.push(
4955
4945
  { $sort: { [req.body.sortColumnName]: req.body.sortBy } },
@@ -5025,31 +5015,8 @@ export async function getRolloutDetails( req, res ) {
5025
5015
  },
5026
5016
  { $count: 'count' },
5027
5017
  ],
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,
5018
+ data: [ ...extraCondition, { $skip: skip },
5019
+ { $limit: limit } ],
5053
5020
  count: [
5054
5021
  ...extraCondition,
5055
5022
  { $count: 'total' },
@@ -5058,7 +5025,37 @@ export async function getRolloutDetails( req, res ) {
5058
5025
  } );
5059
5026
 
5060
5027
 
5061
- let rolloutDetails = await storeBuilderService.aggregate( query );
5028
+ let floorQuery = [
5029
+ {
5030
+ $match: {
5031
+ clientId: req.body.clientId,
5032
+ storeId: { $in: storeDetails },
5033
+ },
5034
+ },
5035
+ {
5036
+ $group: {
5037
+ _id: '$storeId',
5038
+ count: { $sum: 1 },
5039
+ },
5040
+ },
5041
+ {
5042
+ $match: {
5043
+ count: { $gt: 1 },
5044
+ },
5045
+ },
5046
+ {
5047
+ $group: {
5048
+ _id: '',
5049
+ storeList: { $addToSet: '$_id' },
5050
+ },
5051
+ },
5052
+ ];
5053
+
5054
+
5055
+ let [ rolloutDetails, doubleFloorList ] = await Promise.all( [
5056
+ storeBuilderService.aggregate( query ),
5057
+ storeBuilderService.aggregate( floorQuery ),
5058
+ ] );
5062
5059
  let result = {
5063
5060
  cardData: {
5064
5061
  totalStore: rolloutDetails?.[0]?.totalStore?.[0]?.count || 0,
@@ -5067,7 +5064,7 @@ export async function getRolloutDetails( req, res ) {
5067
5064
  vmPendingStore: rolloutDetails?.[0]?.vmPending?.[0]?.count || 0,
5068
5065
  flagStore: rolloutDetails?.[0]?.flag?.[0]?.count || 0,
5069
5066
  flagStore: rolloutDetails?.[0]?.flag?.[0]?.count || 0,
5070
- doubleFloorStore: rolloutDetails?.[0]?.doubleFloorStore?.[0]?.doubleFloorList || [],
5067
+ doubleFloorStore: doubleFloorList[0]?.storeList|| [],
5071
5068
  },
5072
5069
  tableData: {
5073
5070
  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' }, date_iso: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) }, ...( 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 } );