tango-app-api-store-builder 1.0.0-beta-177 → 1.0.0-beta-179
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 +3 -3
- package/src/controllers/fixtureTemplate.controller.js +1 -36
- package/src/controllers/managePlano.controller.js +11 -143
- package/src/controllers/planoLibrary.controller.js +19 -1
- package/src/controllers/script.controller.js +1 -1
- package/src/controllers/storeBuilder.controller.js +16 -979
- package/src/controllers/task.controller.js +124 -154
- package/src/routes/managePlano.routes.js +1 -3
- package/src/routes/storeBuilder.routes.js +1 -3
- package/src/routes/task.routes.js +1 -2
- package/src/service/storeFixture.service.js +1 -4
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-179",
|
|
4
4
|
"description": "storeBuilder",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,8 +32,8 @@
|
|
|
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.
|
|
36
|
-
"tango-app-api-middleware": "3.1.48",
|
|
35
|
+
"tango-api-schema": "^2.2.152",
|
|
36
|
+
"tango-app-api-middleware": "^3.1.48",
|
|
37
37
|
"url": "^0.11.4",
|
|
38
38
|
"winston": "^3.17.0",
|
|
39
39
|
"winston-daily-rotate-file": "^5.0.0",
|
|
@@ -542,42 +542,7 @@ export async function getAllTemplates( req, res ) {
|
|
|
542
542
|
return res.sendError( 'Client Id is required', 400 );
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
const
|
|
546
|
-
{
|
|
547
|
-
$match: {
|
|
548
|
-
clientId: req.body.clientId,
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
$project: {
|
|
553
|
-
'fixtureName': 1,
|
|
554
|
-
'fixtureWidth': 1,
|
|
555
|
-
'productBrandName': {
|
|
556
|
-
$cond: {
|
|
557
|
-
if: { $eq: [ '$productResolutionLevel', 'L1' ] },
|
|
558
|
-
then: '$productBrandName',
|
|
559
|
-
else: {
|
|
560
|
-
$reduce: {
|
|
561
|
-
input: {
|
|
562
|
-
$map: {
|
|
563
|
-
input: '$shelfConfig',
|
|
564
|
-
as: 'shelf',
|
|
565
|
-
in: '$$shelf.productBrandName',
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
initialValue: [],
|
|
569
|
-
in: {
|
|
570
|
-
$setUnion: [ '$$value', '$$this' ],
|
|
571
|
-
},
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
},
|
|
577
|
-
},
|
|
578
|
-
];
|
|
579
|
-
|
|
580
|
-
const fixtureTemplates = await fixtureConfigService.aggregate( query );
|
|
545
|
+
const fixtureTemplates = await fixtureConfigService.find( { clientId: req.body.clientId }, { fixtureName: 1, fixtureWidth: 1, productBrandName: 1 } );
|
|
581
546
|
|
|
582
547
|
res.sendSuccess( fixtureTemplates );
|
|
583
548
|
} catch ( e ) {
|
|
@@ -73,14 +73,13 @@ 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 ) {
|
|
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: new mongoose.Types.ObjectId( taskId ) } ),
|
|
84
83
|
...( filterByStatus?.length ? { status: { $in: filterByStatus } } : {} ),
|
|
85
84
|
},
|
|
86
85
|
};
|
|
@@ -145,33 +144,30 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
145
144
|
$match: { $expr: { $eq: [ '$_id', '$$fixtureId' ] } },
|
|
146
145
|
},
|
|
147
146
|
],
|
|
148
|
-
as: '
|
|
147
|
+
as: 'storeFixtureData',
|
|
149
148
|
},
|
|
150
149
|
},
|
|
151
150
|
{
|
|
152
|
-
$unwind: { path: '$
|
|
151
|
+
$unwind: { path: '$storeFixtureData', preserveNullAndEmptyArrays: true },
|
|
153
152
|
},
|
|
154
153
|
{
|
|
155
154
|
$lookup: {
|
|
156
|
-
from: '
|
|
157
|
-
let: {
|
|
155
|
+
from: 'fixtureconfigs',
|
|
156
|
+
let: { fixtureConfigId: '$storeFixtureData.fixtureConfigId' },
|
|
158
157
|
pipeline: [
|
|
159
158
|
{
|
|
160
|
-
$match: { $expr: { $eq: [ '$
|
|
159
|
+
$match: { $expr: { $eq: [ '$_id', '$$fixtureConfigId' ] } },
|
|
161
160
|
},
|
|
162
161
|
],
|
|
163
|
-
as: '
|
|
162
|
+
as: 'FixtureData',
|
|
164
163
|
},
|
|
165
164
|
},
|
|
166
|
-
|
|
167
165
|
{
|
|
168
|
-
$
|
|
169
|
-
'FixtureData.shelfConfig': '$Fixtureshelves',
|
|
170
|
-
},
|
|
166
|
+
$unwind: { path: '$FixtureData', preserveNullAndEmptyArrays: true },
|
|
171
167
|
},
|
|
172
168
|
];
|
|
173
169
|
|
|
174
|
-
const vmStages =
|
|
170
|
+
const vmStages = type === 'vm' ? [
|
|
175
171
|
{
|
|
176
172
|
$unwind: { path: '$FixtureData.vmConfig', preserveNullAndEmptyArrays: true },
|
|
177
173
|
},
|
|
@@ -184,7 +180,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
184
180
|
$match: { $expr: { $eq: [ '$_id', '$$vmId' ] } },
|
|
185
181
|
},
|
|
186
182
|
{
|
|
187
|
-
$project: { vmName: 1
|
|
183
|
+
$project: { vmName: 1 },
|
|
188
184
|
},
|
|
189
185
|
],
|
|
190
186
|
as: 'vmDetails',
|
|
@@ -196,7 +192,6 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
196
192
|
{
|
|
197
193
|
$set: {
|
|
198
194
|
'FixtureData.vmConfig.vmName': '$vmDetails.vmName',
|
|
199
|
-
'FixtureData.vmConfig.vmType': '$vmDetails.vmType',
|
|
200
195
|
},
|
|
201
196
|
},
|
|
202
197
|
{
|
|
@@ -312,7 +307,7 @@ function buildPipelineByType( type, planoId, floorId, filterByStatus, filterByAp
|
|
|
312
307
|
pipeline.push( { $sort: { _id: -1 } } );
|
|
313
308
|
}
|
|
314
309
|
|
|
315
|
-
|
|
310
|
+
|
|
316
311
|
return pipeline;
|
|
317
312
|
}
|
|
318
313
|
|
|
@@ -652,78 +647,6 @@ export async function updateFixtureStatus( req, res ) {
|
|
|
652
647
|
}
|
|
653
648
|
}
|
|
654
649
|
|
|
655
|
-
export async function updateRolloutStatus( req, res ) {
|
|
656
|
-
try {
|
|
657
|
-
let comments = {
|
|
658
|
-
userId: req.user._id,
|
|
659
|
-
userName: req.user.userName,
|
|
660
|
-
role: req.user.role,
|
|
661
|
-
responsetype: req.body.type,
|
|
662
|
-
comment: req.body.comments,
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
let updateResponse = await planoTaskService.updateOnefilters(
|
|
666
|
-
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
667
|
-
{
|
|
668
|
-
$set: { 'answers.$[ans].issues.$[iss].Details.$[det].status': req.body.type },
|
|
669
|
-
},
|
|
670
|
-
[
|
|
671
|
-
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
672
|
-
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
673
|
-
{ 'det._id': new mongoose.Types.ObjectId( req.body.DetailsId ) },
|
|
674
|
-
|
|
675
|
-
] );
|
|
676
|
-
if ( updateResponse && updateResponse.answers.length > 0 ) {
|
|
677
|
-
let findissuse = updateResponse.answers[0].issues.filter( ( data ) => data._id == req.body.issueId );
|
|
678
|
-
let findDetails = findissuse[0].Details.filter( ( det ) => det.status === 'agree' );
|
|
679
|
-
if ( findissuse[0].Details.length === findDetails.length ) {
|
|
680
|
-
await planoTaskService.updateOnefilters(
|
|
681
|
-
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
682
|
-
{
|
|
683
|
-
$set: { 'answers.$[ans].issues.$[iss].status': 'completed' },
|
|
684
|
-
},
|
|
685
|
-
[
|
|
686
|
-
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
687
|
-
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
688
|
-
] );
|
|
689
|
-
}
|
|
690
|
-
let findoneplanoData = await planoTaskService.findOne( { _id: new mongoose.Types.ObjectId( req.body._id ) } );
|
|
691
|
-
let totalApproved = findoneplanoData.answers[0].issues.filter( ( data ) => data.status === 'pending' );
|
|
692
|
-
if ( totalApproved.length === 0 ) {
|
|
693
|
-
await planoTaskService.updateOne(
|
|
694
|
-
{
|
|
695
|
-
_id: new mongoose.Types.ObjectId( req.body._id ),
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
'status': 'complete',
|
|
699
|
-
},
|
|
700
|
-
);
|
|
701
|
-
let data = {};
|
|
702
|
-
if ( req.body.taskType == 'vmRollout' ) {
|
|
703
|
-
data['isVmEdited'] = false;
|
|
704
|
-
} else {
|
|
705
|
-
data['isMerchEdited'] = false;
|
|
706
|
-
}
|
|
707
|
-
await storeFixtureService.updateOne( { _id: updateResponse.fixtureId }, data );
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
await planoTaskService.updateOnefilters(
|
|
711
|
-
{ _id: new mongoose.Types.ObjectId( req.body._id ) },
|
|
712
|
-
{
|
|
713
|
-
$push: { 'answers.$[ans].issues.$[iss].comments': comments },
|
|
714
|
-
},
|
|
715
|
-
[
|
|
716
|
-
{ 'ans._id': new mongoose.Types.ObjectId( req.body.answerId ) },
|
|
717
|
-
{ 'iss._id': new mongoose.Types.ObjectId( req.body.issueId ) },
|
|
718
|
-
] );
|
|
719
|
-
res.sendSuccess( 'updated successfully' );
|
|
720
|
-
} catch ( e ) {
|
|
721
|
-
logger.error( { functionName: 'updateFixtureStatus', error: e } );
|
|
722
|
-
return res.sendError( e, 500 );
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
|
|
727
650
|
export async function updateStoreFixture( req, res ) {
|
|
728
651
|
try {
|
|
729
652
|
const { fixtureId, data } = req.body;
|
|
@@ -967,60 +890,5 @@ export async function getPlanoRevisionById( req, res ) {
|
|
|
967
890
|
res.sendError( 'Failed to fetch plano revision', 500 );
|
|
968
891
|
}
|
|
969
892
|
}
|
|
970
|
-
export async function getRolloutFeedback( req, res ) {
|
|
971
|
-
try {
|
|
972
|
-
const taskTypes = req.body.filterByTask && req.body.filterByTask.length > 0 ? req.body.filterByTask : [ 'merchRollout', 'vmRollout' ];
|
|
973
|
-
const filterByStatus = req.body.filterByStatus || [];
|
|
974
|
-
const filterByApprovalStatus = req.body.filterByApprovalStatus || '';
|
|
975
|
-
const resultMap = {};
|
|
976
|
-
const commentMap = {};
|
|
977
|
-
await Promise.all(
|
|
978
|
-
taskTypes.map( async ( type, index ) => {
|
|
979
|
-
console.log( type );
|
|
980
|
-
const pipeline = buildPipelineByType( type, req.body.planoId, req.body.floorId, filterByStatus, filterByApprovalStatus, req.body.showtask, req.body.taskId );
|
|
981
|
-
|
|
982
|
-
let data = await planoTaskService.aggregate( pipeline );
|
|
983
|
-
console.log( data );
|
|
984
|
-
if ( filterByApprovalStatus && filterByApprovalStatus !== '' ) {
|
|
985
|
-
console.log( '-------------1', filterByApprovalStatus );
|
|
986
|
-
data.forEach( ( element ) => {
|
|
987
|
-
element.answers?.forEach( ( ans ) => {
|
|
988
|
-
ans.issues = ans.issues?.filter(
|
|
989
|
-
( issue ) => issue.Details && issue.Details.length > 0,
|
|
990
|
-
);
|
|
991
|
-
} );
|
|
992
|
-
element.answers = element.answers?.filter(
|
|
993
|
-
( ans ) => ans.issues && ans.issues.length > 0,
|
|
994
|
-
);
|
|
995
|
-
} );
|
|
996
|
-
data = data.filter(
|
|
997
|
-
( element ) => element.answers && element.answers.length > 0,
|
|
998
|
-
);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
resultMap[type] = data;
|
|
1003
|
-
|
|
1004
|
-
const comments = await planoGlobalCommentService.find( {
|
|
1005
|
-
planoId: new mongoose.Types.ObjectId( req.body.planoId ),
|
|
1006
|
-
floorId: new mongoose.Types.ObjectId( req.body.floorId ),
|
|
1007
|
-
taskType: type,
|
|
1008
|
-
} );
|
|
1009
|
-
commentMap[type] = comments;
|
|
1010
|
-
} ),
|
|
1011
|
-
);
|
|
1012
|
-
const response = {
|
|
1013
|
-
merchRolloutData: resultMap['merchRollout'] || [],
|
|
1014
|
-
vmRolloutData: resultMap['vmRollout'] || [],
|
|
1015
|
-
merchRolloutComment: commentMap['merchRollout'] || [],
|
|
1016
|
-
vmRolloutComment: commentMap['vmRollout'] || [],
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
res.sendSuccess( response );
|
|
1020
|
-
} catch ( e ) {
|
|
1021
|
-
logger.error( { functionName: 'getRolloutFeedback', error: e } );
|
|
1022
|
-
return res.sendError( e, 500 );
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
893
|
|
|
1026
894
|
|
|
@@ -123,6 +123,24 @@ async function getMaxFixtureLibCode() {
|
|
|
123
123
|
export async function createFixture( req, res ) {
|
|
124
124
|
try {
|
|
125
125
|
let FixLibCode = await getMaxFixtureLibCode();
|
|
126
|
+
let query = [
|
|
127
|
+
{
|
|
128
|
+
$addFields: {
|
|
129
|
+
fixtureCategoryLower: { $toLower: '$fixtureCategory' },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
$match: {
|
|
134
|
+
'clientId': req.body.clientId,
|
|
135
|
+
'fixtureCategoryLower': req.body.fixtureCategory.toLowerCase(),
|
|
136
|
+
'fixtureWidth.value': 10,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
let fixLibDetails = await planoLibraryService.aggregate( query );
|
|
141
|
+
if ( fixLibDetails.length ) {
|
|
142
|
+
return res.sendError( `Fixture Name ${req.body.fixtureCategory} already Exists`, 400 );
|
|
143
|
+
}
|
|
126
144
|
let data ={
|
|
127
145
|
clientId: req.body.clientId,
|
|
128
146
|
fixtureCategory: req.body.fixtureCategory,
|
|
@@ -166,7 +184,7 @@ export async function updateFixture( req, res ) {
|
|
|
166
184
|
'clientId': req.body.clientId,
|
|
167
185
|
'fixtureCategoryLower': req.body.fixtureCategory.toLowerCase(),
|
|
168
186
|
'fixtureWidth.value': req.body.fixtureWidth.value,
|
|
169
|
-
'_id': { $ne:
|
|
187
|
+
'_id': { $ne: req.params.fixtureId },
|
|
170
188
|
},
|
|
171
189
|
},
|
|
172
190
|
];
|
|
@@ -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: ['LKST98', 'LKST682', 'ST185', 'ST36', 'LKST1193'] } },
|
|
7404
7404
|
// { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
|
|
7405
7405
|
],
|
|
7406
7406
|
};
|