tango-app-api-store-builder 1.0.0-beta-159 → 1.0.0-beta-161
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 +2 -2
- package/src/controllers/managePlano.controller.js +75 -2
- package/src/controllers/script.controller.js +1 -1
- package/src/controllers/storeBuilder.controller.js +68 -11
- package/src/controllers/task.controller.js +5 -1
- package/src/routes/managePlano.routes.js +2 -1
- package/src/routes/task.routes.js +2 -1
- package/src/service/storeFixture.service.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-store-builder",
|
|
3
|
-
"version": "1.0.0-beta-
|
|
3
|
+
"version": "1.0.0-beta-161",
|
|
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.
|
|
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",
|
|
@@ -167,7 +167,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
167
167
|
},
|
|
168
168
|
];
|
|
169
169
|
|
|
170
|
-
const vmStages =
|
|
170
|
+
const vmStages = [ 'vm', 'vmRollout' ].includes( type ) ? [
|
|
171
171
|
{
|
|
172
172
|
$unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
|
|
173
173
|
},
|
|
@@ -180,7 +180,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
180
180
|
$match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
|
-
$project: { vmName: 1 },
|
|
183
|
+
$project: { vmName: 1, vmType: 1 },
|
|
184
184
|
},
|
|
185
185
|
],
|
|
186
186
|
as: 'vmDetails',
|
|
@@ -192,6 +192,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
192
192
|
{
|
|
193
193
|
$set: {
|
|
194
194
|
'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
|
|
195
|
+
'FixtureData.vmConfig.vmType': '$vmDetails.vmType',
|
|
195
196
|
},
|
|
196
197
|
},
|
|
197
198
|
{
|
|
@@ -647,6 +648,78 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
647
648
|
}
|
|
648
649
|
}
|
|
649
650
|
|
|
651
|
+
export async function updateRolloutStatus( req, res ) {
|
|
652
|
+
try {
|
|
653
|
+
let comments = {
|
|
654
|
+
userId: req.user._id,
|
|
655
|
+
userName: req.user.userName,
|
|
656
|
+
role: req.user.role,
|
|
657
|
+
responsetype: req.body.type,
|
|
658
|
+
comment: req.body.comments,
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
let updateResponse = await planoTaskService.updateOnefilters(
|
|
662
|
+
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
663
|
+
{
|
|
664
|
+
$set: { 'answers.$[ans].issues.$[iss].Details.$[det].status': req.body.type },
|
|
665
|
+
},
|
|
666
|
+
[
|
|
667
|
+
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
668
|
+
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
669
|
+
{ 'det._id': new mongoose.Types.ObjectId( req.body.DetailsId ) },
|
|
670
|
+
|
|
671
|
+
] );
|
|
672
|
+
if ( updateResponse && updateResponse.answers.length > 0 ) {
|
|
673
|
+
let findissuse = updateResponse.answers[0].issues.filter( ( data ) => data._id == req.body.issueId );
|
|
674
|
+
let findDetails = findissuse[0].Details.filter( ( det ) => det.status === 'agree' );
|
|
675
|
+
if ( findissuse[0].Details.length === findDetails.length ) {
|
|
676
|
+
await planoTaskService.updateOnefilters(
|
|
677
|
+
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
678
|
+
{
|
|
679
|
+
$set: { 'answers.$[ans].issues.$[iss].status': 'completed' },
|
|
680
|
+
},
|
|
681
|
+
[
|
|
682
|
+
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
683
|
+
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
684
|
+
] );
|
|
685
|
+
}
|
|
686
|
+
let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
|
|
687
|
+
let totalApproved = findoneplanoData.answers[0].issues.filter( ( data ) => data.status === 'pending' );
|
|
688
|
+
if ( totalApproved.length === 0 ) {
|
|
689
|
+
await planoTaskService.updateOne(
|
|
690
|
+
{
|
|
691
|
+
_id: new mongoose.Types.ObjectId( req.body._id ),
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
'status': 'complete',
|
|
695
|
+
},
|
|
696
|
+
);
|
|
697
|
+
let data = {};
|
|
698
|
+
if ( req.body.type == 'vmRollout' ) {
|
|
699
|
+
data['isVmEdited'] = false;
|
|
700
|
+
} else {
|
|
701
|
+
data['isMerchEdited'] = false;
|
|
702
|
+
}
|
|
703
|
+
await storeFixtureService.updateOne( { _id: updateResponse.fixtureId }, data );
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
await planoTaskService.updateOnefilters(
|
|
707
|
+
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
708
|
+
{
|
|
709
|
+
$push: { 'answers.$[ans].issues.$[iss].comments': comments },
|
|
710
|
+
},
|
|
711
|
+
[
|
|
712
|
+
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
713
|
+
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
714
|
+
] );
|
|
715
|
+
res.sendSuccess( 'updated successfully' );
|
|
716
|
+
} catch ( e ) {
|
|
717
|
+
logger.error( { functionName: 'updateFixtureStatus', error: e } );
|
|
718
|
+
return res.sendError( e, 500 );
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
|
|
650
723
|
export async function updateStoreFixture( req, res ) {
|
|
651
724
|
try {
|
|
652
725
|
const { fixtureId, data } = req.body;
|
|
@@ -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: [
|
|
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
|
|
1471
|
-
if ( !productData ) {
|
|
1472
|
-
|
|
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
|
|
5332
|
-
await
|
|
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 );
|
|
@@ -1031,7 +1031,11 @@ export async function redoTask( req, res ) {
|
|
|
1031
1031
|
|
|
1032
1032
|
export async function revokeTask( req, res ) {
|
|
1033
1033
|
try {
|
|
1034
|
-
|
|
1034
|
+
if ( !req.body.taskId ) {
|
|
1035
|
+
return res.sendError( 'Checklist type is required', 400 );
|
|
1036
|
+
}
|
|
1037
|
+
await processedService.deleteMany( { _id: req.body.taskId } );
|
|
1038
|
+
return res.sendSuccess( 'Task revoked successfully' );
|
|
1035
1039
|
} catch ( e ) {
|
|
1036
1040
|
logger.error( { functionName: 'revokeTask', error: e } );
|
|
1037
1041
|
return res.sendError( e, 500 );
|
|
@@ -21,4 +21,5 @@ managePlanoRouter
|
|
|
21
21
|
.post( '/createRevision', managePlanoController.createPlanoRevision )
|
|
22
22
|
.post( '/getRevisions', managePlanoController.getAllPlanoRevisions )
|
|
23
23
|
.post( '/getRevisionData', managePlanoController.getPlanoRevisionById )
|
|
24
|
-
.post( '/getRolloutFeedback', managePlanoController.getRolloutFeedback )
|
|
24
|
+
.post( '/getRolloutFeedback', managePlanoController.getRolloutFeedback )
|
|
25
|
+
.post( '/updateRolloutStatus', isAllowedSessionHandler, managePlanoController.updateRolloutStatus );
|
|
@@ -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
|
+
}
|