tango-app-api-store-builder 1.0.0-beta-163 → 1.0.0-beta-165
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
|
@@ -73,13 +73,14 @@ export async function getplanoFeedback( req, res ) {
|
|
|
73
73
|
return res.sendError( e, 500 );
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByApprovalStatus, showtask ) {
|
|
76
|
+
function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByApprovalStatus, showtask, taskId=0 ) {
|
|
77
77
|
console.log( type, planoId, floorId, filterByStatus );
|
|
78
78
|
const matchStage = {
|
|
79
79
|
$match: {
|
|
80
80
|
planoId: new mongoose.Types.ObjectId( planoId ),
|
|
81
81
|
floorId: new mongoose.Types.ObjectId( floorId ),
|
|
82
82
|
type: type,
|
|
83
|
+
...( taskId && { taskId: taskId } ),
|
|
83
84
|
...( filterByStatus?.length ? { status: { $in: filterByStatus } } : {} ),
|
|
84
85
|
},
|
|
85
86
|
};
|
|
@@ -695,7 +696,7 @@ export async function updateRolloutStatus( req, res ) {
|
|
|
695
696
|
},
|
|
696
697
|
);
|
|
697
698
|
let data = {};
|
|
698
|
-
if ( req.body.
|
|
699
|
+
if ( req.body.taskType == 'vmRollout' ) {
|
|
699
700
|
data['isVmEdited'] = false;
|
|
700
701
|
} else {
|
|
701
702
|
data['isMerchEdited'] = false;
|
|
@@ -973,7 +974,7 @@ export async function getRolloutFeedback( req, res ) {
|
|
|
973
974
|
await Promise.all(
|
|
974
975
|
taskTypes.map( async ( type, index ) => {
|
|
975
976
|
console.log( type );
|
|
976
|
-
const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask );
|
|
977
|
+
const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask, req.body.taskId );
|
|
977
978
|
|
|
978
979
|
let data = await planoTaskService.aggregate( pipeline );
|
|
979
980
|
console.log( data );
|
|
@@ -1451,7 +1451,7 @@ 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')
|
|
1454
|
+
console.log( 'called' );
|
|
1455
1455
|
|
|
1456
1456
|
await Promise.all(
|
|
1457
1457
|
fixtureShelves.map( async ( shelf ) => {
|
|
@@ -3016,6 +3016,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3016
3016
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
3017
3017
|
|
|
3018
3018
|
const compliance = await planoTaskComplianceService.findAndSort( {
|
|
3019
|
+
...( ( [ 'merchRollout', 'vmRollout' ].includes( req.body?.type )&& req?.body?.taskId ) && { taskId: req.body.taskId } ),
|
|
3019
3020
|
fixtureId: fixture._id,
|
|
3020
3021
|
type: req.body?.type ? req.body.type : 'fixture',
|
|
3021
3022
|
}, { status: 1, answers: 1, taskType: 1 }, { _id: -1 } );
|
|
@@ -3116,6 +3117,7 @@ export async function storeFixturesTaskv2( req, res ) {
|
|
|
3116
3117
|
const vmCount = await planoMappingService.count( { fixtureId: fixture._id, type: 'vm' } );
|
|
3117
3118
|
|
|
3118
3119
|
const compliance = await planoTaskComplianceService.findAndSort( {
|
|
3120
|
+
...( ( [ 'merchRollout', 'vmRollout' ].includes( req.body?.type )&& req?.body?.taskId ) && { taskId: req.body.taskId } ),
|
|
3119
3121
|
fixtureId: fixture._id,
|
|
3120
3122
|
type: req.body?.type ? req.body.type : 'fixture',
|
|
3121
3123
|
}, { status: 1, answers: 1, taskType: 1 }, { _id: -1 } );
|
|
@@ -4766,11 +4768,11 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4766
4768
|
branches: [
|
|
4767
4769
|
{
|
|
4768
4770
|
case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchPending', 0 ] } ] },
|
|
4769
|
-
then: '
|
|
4771
|
+
then: 'pending',
|
|
4770
4772
|
},
|
|
4771
4773
|
{
|
|
4772
4774
|
case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchDisagree', 0 ] } ] },
|
|
4773
|
-
then: '
|
|
4775
|
+
then: 'disagree',
|
|
4774
4776
|
},
|
|
4775
4777
|
],
|
|
4776
4778
|
default: '',
|
|
@@ -4781,11 +4783,11 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4781
4783
|
branches: [
|
|
4782
4784
|
{
|
|
4783
4785
|
case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmPending', 0 ] } ] },
|
|
4784
|
-
then: '
|
|
4786
|
+
then: 'pending',
|
|
4785
4787
|
},
|
|
4786
4788
|
{
|
|
4787
4789
|
case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmDisagree', 0 ] } ] },
|
|
4788
|
-
then: '
|
|
4790
|
+
then: 'disagree',
|
|
4789
4791
|
},
|
|
4790
4792
|
],
|
|
4791
4793
|
default: '',
|
|
@@ -4797,10 +4799,19 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4797
4799
|
as: 'taskFeedback',
|
|
4798
4800
|
},
|
|
4799
4801
|
},
|
|
4802
|
+
{
|
|
4803
|
+
$set: {
|
|
4804
|
+
taskFeedback: {
|
|
4805
|
+
$ifNull: [ { $arrayElemAt: [ '$taskFeedback', 0 ] }, {} ],
|
|
4806
|
+
},
|
|
4807
|
+
},
|
|
4808
|
+
},
|
|
4800
4809
|
];
|
|
4801
4810
|
|
|
4811
|
+
let extraCondition = [];
|
|
4812
|
+
|
|
4802
4813
|
if ( req.body?.filter?.type == 'rollout' ) {
|
|
4803
|
-
|
|
4814
|
+
extraCondition.push( {
|
|
4804
4815
|
$match: {
|
|
4805
4816
|
$expr: {
|
|
4806
4817
|
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
@@ -4816,7 +4827,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4816
4827
|
taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } },
|
|
4817
4828
|
},
|
|
4818
4829
|
{
|
|
4819
|
-
|
|
4830
|
+
'taskFeedback.fixtureStatus': 'pending',
|
|
4820
4831
|
},
|
|
4821
4832
|
];
|
|
4822
4833
|
} else {
|
|
@@ -4825,12 +4836,12 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4825
4836
|
taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } },
|
|
4826
4837
|
},
|
|
4827
4838
|
{
|
|
4828
|
-
|
|
4839
|
+
'taskFeedback.vmStatus': 'pending',
|
|
4829
4840
|
},
|
|
4830
4841
|
];
|
|
4831
4842
|
}
|
|
4832
4843
|
|
|
4833
|
-
|
|
4844
|
+
extraCondition.push( {
|
|
4834
4845
|
$match: {
|
|
4835
4846
|
$and: andCondition,
|
|
4836
4847
|
},
|
|
@@ -4838,18 +4849,17 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4838
4849
|
}
|
|
4839
4850
|
|
|
4840
4851
|
if ( req.body.filter?.type == 'flag' ) {
|
|
4841
|
-
|
|
4852
|
+
extraCondition.push( {
|
|
4842
4853
|
$match: {
|
|
4843
4854
|
$and: [
|
|
4844
4855
|
{
|
|
4845
|
-
taskDetails: { $elemMatch: { breach: true } },
|
|
4856
|
+
taskDetails: { $elemMatch: { breach: true, status: { $ne: 'submit' } } },
|
|
4846
4857
|
},
|
|
4847
4858
|
],
|
|
4848
4859
|
},
|
|
4849
4860
|
} );
|
|
4850
4861
|
}
|
|
4851
4862
|
|
|
4852
|
-
let extraCondition = [];
|
|
4853
4863
|
|
|
4854
4864
|
if ( req.body.searchValue ) {
|
|
4855
4865
|
extraCondition.push( {
|
|
@@ -4859,56 +4869,59 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4859
4869
|
} );
|
|
4860
4870
|
}
|
|
4861
4871
|
|
|
4862
|
-
if ( req.body.filter
|
|
4872
|
+
if ( req.body.filter?.status?.length ) {
|
|
4873
|
+
const orCondition = [];
|
|
4874
|
+
|
|
4863
4875
|
if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
|
|
4864
|
-
|
|
4865
|
-
$
|
|
4866
|
-
$
|
|
4867
|
-
$eq: [ { $size: '$taskDetails' }, 0 ],
|
|
4868
|
-
},
|
|
4876
|
+
orCondition.push( {
|
|
4877
|
+
$expr: {
|
|
4878
|
+
$eq: [ { $size: '$taskDetails' }, 0 ],
|
|
4869
4879
|
},
|
|
4870
4880
|
} );
|
|
4871
4881
|
}
|
|
4882
|
+
|
|
4872
4883
|
if ( req.body.filter.status.includes( 'taskAssigned' ) ) {
|
|
4873
|
-
|
|
4874
|
-
$
|
|
4875
|
-
$
|
|
4876
|
-
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
4877
|
-
},
|
|
4884
|
+
orCondition.push( {
|
|
4885
|
+
$expr: {
|
|
4886
|
+
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
4878
4887
|
},
|
|
4879
4888
|
} );
|
|
4880
4889
|
}
|
|
4890
|
+
|
|
4881
4891
|
if ( req.body.filter.status.includes( 'reviewPending' ) ) {
|
|
4882
|
-
|
|
4883
|
-
$
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4892
|
+
orCondition.push( {
|
|
4893
|
+
$or: [
|
|
4894
|
+
{
|
|
4895
|
+
$and: [
|
|
4896
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
4897
|
+
{ 'taskFeedback.fixtureStatus': 'pending' },
|
|
4898
|
+
],
|
|
4899
|
+
},
|
|
4900
|
+
{
|
|
4901
|
+
$and: [
|
|
4902
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
4903
|
+
{ 'taskFeedback.vmStatus': 'pending' },
|
|
4904
|
+
],
|
|
4905
|
+
},
|
|
4906
|
+
],
|
|
4893
4907
|
} );
|
|
4894
4908
|
}
|
|
4909
|
+
|
|
4895
4910
|
if ( req.body.filter.status.includes( 'completed' ) ) {
|
|
4896
|
-
|
|
4897
|
-
$
|
|
4898
|
-
$
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } },
|
|
4904
|
-
},
|
|
4905
|
-
{
|
|
4906
|
-
$expr: { $eq: [ { $size: '$compliance' }, 0 ] },
|
|
4911
|
+
orCondition.push( {
|
|
4912
|
+
$and: [
|
|
4913
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
4914
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
4915
|
+
{
|
|
4916
|
+
$expr: {
|
|
4917
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
4907
4918
|
},
|
|
4908
|
-
|
|
4909
|
-
|
|
4919
|
+
},
|
|
4920
|
+
],
|
|
4910
4921
|
} );
|
|
4911
4922
|
}
|
|
4923
|
+
|
|
4924
|
+
extraCondition.push( { $match: { $or: orCondition } } );
|
|
4912
4925
|
}
|
|
4913
4926
|
|
|
4914
4927
|
extraCondition.push(
|
|
@@ -4957,9 +4970,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4957
4970
|
},
|
|
4958
4971
|
},
|
|
4959
4972
|
{
|
|
4960
|
-
|
|
4961
|
-
$elemMatch: { feedbackStatus: 'merchPending' },
|
|
4962
|
-
},
|
|
4973
|
+
'taskFeedback.fixtureStatus': 'pending',
|
|
4963
4974
|
},
|
|
4964
4975
|
],
|
|
4965
4976
|
},
|
|
@@ -4976,9 +4987,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4976
4987
|
},
|
|
4977
4988
|
},
|
|
4978
4989
|
{
|
|
4979
|
-
|
|
4980
|
-
$elemMatch: { feedbackStatus: 'vmPending' },
|
|
4981
|
-
},
|
|
4990
|
+
'taskFeedback.vmStatus': 'pending',
|
|
4982
4991
|
},
|
|
4983
4992
|
],
|
|
4984
4993
|
},
|
|
@@ -4989,7 +4998,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4989
4998
|
{
|
|
4990
4999
|
$match: {
|
|
4991
5000
|
taskDetails: {
|
|
4992
|
-
$elemMatch: { breach: true },
|
|
5001
|
+
$elemMatch: { breach: true, status: { $ne: 'submit' } },
|
|
4993
5002
|
},
|
|
4994
5003
|
},
|
|
4995
5004
|
},
|
|
@@ -321,12 +321,12 @@ export async function createTask( req, res ) {
|
|
|
321
321
|
}
|
|
322
322
|
await floorService.updateOne( { _id: taskData?.floorId }, { planoProgress } );
|
|
323
323
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
324
|
+
for ( let j=0; j<req.body.days; j++ ) {
|
|
325
|
+
let currDate = dayjs().add( j, 'days' );
|
|
326
|
+
let time = j ? '12:00 AM' : currDate.format( 'hh:mm A' );
|
|
327
|
+
let insertData = { ...taskData, date_string: currDate.format( 'YYYY-MM-DD' ), date_iso: new Date( currDate.format( 'YYYY-MM-DD' ) ), scheduleStartTime_iso: dayjs.utc( `${currDate.format( 'YYYY-MM-DD' )} ${time}`, 'YYYY-MM-DD hh:mm A' ).format() };
|
|
328
|
+
await processedService.updateOne( { date_string: currDate.format( 'YYYY-MM-DD' ), store_id: insertData.store_id, userEmail: insertData.userEmail, planoId: insertData.planoId, planoType: taskData.planoType, ...( taskData?.floorId ) ? { floorId: taskData.floorId }:{}, ...( [ 'merchRollout', 'vmRollout' ].includes( taskData.planoType ) && { sourceCheckList_id: taskData.sourceCheckList_id } ) }, insertData );
|
|
329
|
+
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
} ) );
|
|
@@ -538,13 +538,13 @@ export async function updateStatus( req, res ) {
|
|
|
538
538
|
email: req.user.email,
|
|
539
539
|
comment: req.body.comments,
|
|
540
540
|
};
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
541
|
+
if ( req.body.status == 'inprogress' ) {
|
|
542
|
+
await processedService.updateOne( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } }, { checklistStatus: 'inprogress', startTime_string: timeString } );
|
|
543
|
+
}
|
|
544
544
|
await processedService.updateOne( { _id: req.body.taskId }, { checklistStatus: req.body.status, ...( req.body.status == 'inprogress' ) ? { startTime_string: timeString } : { submitTime_string: timeString }, comments: { $push: comments } } );
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
545
|
+
if ( req.body.status == 'submit' ) {
|
|
546
|
+
await processedService.deleteMany( { planoId: taskDetails.planoId, userEmail: taskDetails.userEmail, store_id: taskDetails.store_id, ...( taskDetails?.floorId ) ? { floorId: taskDetails.floorId } : {}, date_iso: { $gt: new Date( dayjs().format( 'YYYY-MM-DD' ) ) } } );
|
|
547
|
+
}
|
|
548
548
|
let vmTask = await planoTaskService.find(
|
|
549
549
|
{
|
|
550
550
|
planoId: new mongoose.Types.ObjectId( taskDetails.planoId ),
|