tango-app-api-store-builder 1.0.0-beta-162 → 1.0.0-beta-164
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 ) => {
|
|
@@ -4766,11 +4766,11 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4766
4766
|
branches: [
|
|
4767
4767
|
{
|
|
4768
4768
|
case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchPending', 0 ] } ] },
|
|
4769
|
-
then: '
|
|
4769
|
+
then: 'pending',
|
|
4770
4770
|
},
|
|
4771
4771
|
{
|
|
4772
4772
|
case: { $and: [ { $gt: [ '$merchCount', 0 ] }, { $gt: [ '$merchDisagree', 0 ] } ] },
|
|
4773
|
-
then: '
|
|
4773
|
+
then: 'disagree',
|
|
4774
4774
|
},
|
|
4775
4775
|
],
|
|
4776
4776
|
default: '',
|
|
@@ -4781,11 +4781,11 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4781
4781
|
branches: [
|
|
4782
4782
|
{
|
|
4783
4783
|
case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmPending', 0 ] } ] },
|
|
4784
|
-
then: '
|
|
4784
|
+
then: 'pending',
|
|
4785
4785
|
},
|
|
4786
4786
|
{
|
|
4787
4787
|
case: { $and: [ { $gt: [ '$vmCount', 0 ] }, { $gt: [ '$vmDisagree', 0 ] } ] },
|
|
4788
|
-
then: '
|
|
4788
|
+
then: 'disagree',
|
|
4789
4789
|
},
|
|
4790
4790
|
],
|
|
4791
4791
|
default: '',
|
|
@@ -4797,10 +4797,19 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4797
4797
|
as: 'taskFeedback',
|
|
4798
4798
|
},
|
|
4799
4799
|
},
|
|
4800
|
+
{
|
|
4801
|
+
$set: {
|
|
4802
|
+
taskFeedback: {
|
|
4803
|
+
$ifNull: [ { $arrayElemAt: [ '$taskFeedback', 0 ] }, {} ],
|
|
4804
|
+
},
|
|
4805
|
+
},
|
|
4806
|
+
},
|
|
4800
4807
|
];
|
|
4801
4808
|
|
|
4809
|
+
let extraCondition = [];
|
|
4810
|
+
|
|
4802
4811
|
if ( req.body?.filter?.type == 'rollout' ) {
|
|
4803
|
-
|
|
4812
|
+
extraCondition.push( {
|
|
4804
4813
|
$match: {
|
|
4805
4814
|
$expr: {
|
|
4806
4815
|
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
@@ -4816,7 +4825,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4816
4825
|
taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } },
|
|
4817
4826
|
},
|
|
4818
4827
|
{
|
|
4819
|
-
|
|
4828
|
+
'taskFeedback.fixtureStatus': 'pending',
|
|
4820
4829
|
},
|
|
4821
4830
|
];
|
|
4822
4831
|
} else {
|
|
@@ -4825,12 +4834,12 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4825
4834
|
taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } },
|
|
4826
4835
|
},
|
|
4827
4836
|
{
|
|
4828
|
-
|
|
4837
|
+
'taskFeedback.vmStatus': 'pending',
|
|
4829
4838
|
},
|
|
4830
4839
|
];
|
|
4831
4840
|
}
|
|
4832
4841
|
|
|
4833
|
-
|
|
4842
|
+
extraCondition.push( {
|
|
4834
4843
|
$match: {
|
|
4835
4844
|
$and: andCondition,
|
|
4836
4845
|
},
|
|
@@ -4838,18 +4847,17 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4838
4847
|
}
|
|
4839
4848
|
|
|
4840
4849
|
if ( req.body.filter?.type == 'flag' ) {
|
|
4841
|
-
|
|
4850
|
+
extraCondition.push( {
|
|
4842
4851
|
$match: {
|
|
4843
4852
|
$and: [
|
|
4844
4853
|
{
|
|
4845
|
-
taskDetails: { $elemMatch: { breach: true } },
|
|
4854
|
+
taskDetails: { $elemMatch: { breach: true, status: { $ne: 'submit' } } },
|
|
4846
4855
|
},
|
|
4847
4856
|
],
|
|
4848
4857
|
},
|
|
4849
4858
|
} );
|
|
4850
4859
|
}
|
|
4851
4860
|
|
|
4852
|
-
let extraCondition = [];
|
|
4853
4861
|
|
|
4854
4862
|
if ( req.body.searchValue ) {
|
|
4855
4863
|
extraCondition.push( {
|
|
@@ -4859,56 +4867,59 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4859
4867
|
} );
|
|
4860
4868
|
}
|
|
4861
4869
|
|
|
4862
|
-
if ( req.body.filter
|
|
4870
|
+
if ( req.body.filter?.status?.length ) {
|
|
4871
|
+
const orCondition = [];
|
|
4872
|
+
|
|
4863
4873
|
if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
|
|
4864
|
-
|
|
4865
|
-
$
|
|
4866
|
-
$
|
|
4867
|
-
$eq: [ { $size: '$taskDetails' }, 0 ],
|
|
4868
|
-
},
|
|
4874
|
+
orCondition.push( {
|
|
4875
|
+
$expr: {
|
|
4876
|
+
$eq: [ { $size: '$taskDetails' }, 0 ],
|
|
4869
4877
|
},
|
|
4870
4878
|
} );
|
|
4871
4879
|
}
|
|
4880
|
+
|
|
4872
4881
|
if ( req.body.filter.status.includes( 'taskAssigned' ) ) {
|
|
4873
|
-
|
|
4874
|
-
$
|
|
4875
|
-
$
|
|
4876
|
-
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
4877
|
-
},
|
|
4882
|
+
orCondition.push( {
|
|
4883
|
+
$expr: {
|
|
4884
|
+
$gt: [ { $size: '$taskDetails' }, 0 ],
|
|
4878
4885
|
},
|
|
4879
4886
|
} );
|
|
4880
4887
|
}
|
|
4888
|
+
|
|
4881
4889
|
if ( req.body.filter.status.includes( 'reviewPending' ) ) {
|
|
4882
|
-
|
|
4883
|
-
$
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4890
|
+
orCondition.push( {
|
|
4891
|
+
$or: [
|
|
4892
|
+
{
|
|
4893
|
+
$and: [
|
|
4894
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
4895
|
+
{ 'taskFeedback.fixtureStatus': 'pending' },
|
|
4896
|
+
],
|
|
4897
|
+
},
|
|
4898
|
+
{
|
|
4899
|
+
$and: [
|
|
4900
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
4901
|
+
{ 'taskFeedback.vmStatus': 'pending' },
|
|
4902
|
+
],
|
|
4903
|
+
},
|
|
4904
|
+
],
|
|
4893
4905
|
} );
|
|
4894
4906
|
}
|
|
4907
|
+
|
|
4895
4908
|
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 ] },
|
|
4909
|
+
orCondition.push( {
|
|
4910
|
+
$and: [
|
|
4911
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
4912
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
4913
|
+
{
|
|
4914
|
+
$expr: {
|
|
4915
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
4907
4916
|
},
|
|
4908
|
-
|
|
4909
|
-
|
|
4917
|
+
},
|
|
4918
|
+
],
|
|
4910
4919
|
} );
|
|
4911
4920
|
}
|
|
4921
|
+
|
|
4922
|
+
extraCondition.push( { $match: { $or: orCondition } } );
|
|
4912
4923
|
}
|
|
4913
4924
|
|
|
4914
4925
|
extraCondition.push(
|
|
@@ -4957,9 +4968,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4957
4968
|
},
|
|
4958
4969
|
},
|
|
4959
4970
|
{
|
|
4960
|
-
|
|
4961
|
-
$elemMatch: { feedbackStatus: 'merchPending' },
|
|
4962
|
-
},
|
|
4971
|
+
'taskFeedback.fixtureStatus': 'pending',
|
|
4963
4972
|
},
|
|
4964
4973
|
],
|
|
4965
4974
|
},
|
|
@@ -4976,9 +4985,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4976
4985
|
},
|
|
4977
4986
|
},
|
|
4978
4987
|
{
|
|
4979
|
-
|
|
4980
|
-
$elemMatch: { feedbackStatus: 'vmPending' },
|
|
4981
|
-
},
|
|
4988
|
+
'taskFeedback.vmStatus': 'pending',
|
|
4982
4989
|
},
|
|
4983
4990
|
],
|
|
4984
4991
|
},
|
|
@@ -4989,7 +4996,7 @@ export async function getRolloutDetails( req, res ) {
|
|
|
4989
4996
|
{
|
|
4990
4997
|
$match: {
|
|
4991
4998
|
taskDetails: {
|
|
4992
|
-
$elemMatch: { breach: true },
|
|
4999
|
+
$elemMatch: { breach: true, status: { $ne: 'submit' } },
|
|
4993
5000
|
},
|
|
4994
5001
|
},
|
|
4995
5002
|
},
|
|
@@ -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 ),
|
|
@@ -559,6 +559,20 @@ export async function updateStatus( req, res ) {
|
|
|
559
559
|
await floorService.updateOne( { _id: new mongoose.Types.ObjectId( taskDetails.floorId ) }, { planoProgress: 100 } );
|
|
560
560
|
}
|
|
561
561
|
}
|
|
562
|
+
|
|
563
|
+
if ( req.body.status == 'submit' && [ 'merchRollout', 'vmRollout' ].includes( taskDetails.planoType ) ) {
|
|
564
|
+
let merchVmTaskDetails = await planoTaskService.find(
|
|
565
|
+
{
|
|
566
|
+
planoId: new mongoose.Types.ObjectId( taskDetails.planoId ),
|
|
567
|
+
floorId: new mongoose.Types.ObjectId( taskDetails.floorId ),
|
|
568
|
+
type: taskDetails.planoType,
|
|
569
|
+
status: 'complete',
|
|
570
|
+
},
|
|
571
|
+
{ fixtureId: 1 },
|
|
572
|
+
);
|
|
573
|
+
let query = taskDetails.planoType == 'merchRollout' ? { isMerchEdited: false } : { isVmEdited: false };
|
|
574
|
+
await storeFixtureService.updateMany( { _id: { $in: merchVmTaskDetails?.map( ( ele ) => ele.fixtureId ) } }, query );
|
|
575
|
+
}
|
|
562
576
|
return res.sendSuccess( 'Task status updated successfully' );
|
|
563
577
|
} catch ( e ) {
|
|
564
578
|
logger.error( { functionName: 'storeLayout', error: e } );
|
|
@@ -669,11 +683,6 @@ export async function updateAnswersv2( req, res ) {
|
|
|
669
683
|
await sendMessageToQueue( `${sqs.url}${sqs.storeBuilder}`, JSON.stringify( sqsData ) );
|
|
670
684
|
}
|
|
671
685
|
|
|
672
|
-
if ( data.status == 'complete' && [ 'merchRollout', 'vmRollout' ].includes( data.type ) ) {
|
|
673
|
-
let query = data.type == 'merchRollout' ? { isMerchEdited: false } : { isVmEdited: false };
|
|
674
|
-
await storeFixtureService.updateOne( { _id: req.body.fixtureId }, query );
|
|
675
|
-
}
|
|
676
|
-
|
|
677
686
|
return res.sendSuccess( 'Fixture details updated successfully' );
|
|
678
687
|
} catch ( e ) {
|
|
679
688
|
logger.error( { functionName: 'updateAnswers', error: e } );
|