tango-app-api-store-builder 1.0.0-beta-187 → 1.0.0-beta-189
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
|
@@ -8,6 +8,7 @@ import * as processedTaskService from '../service/processedTaskservice.js';
|
|
|
8
8
|
import * as fixtureShelfService from '../service/fixtureShelf.service.js';
|
|
9
9
|
import * as vmService from '../service/planoVm.service.js';
|
|
10
10
|
import * as templateLogService from '../service/templateLog.service.js';
|
|
11
|
+
import * as storeLayoutService from '../service/storeBuilder.service.js';
|
|
11
12
|
import { createTask } from './task.controller.js';
|
|
12
13
|
import mongoose from 'mongoose';
|
|
13
14
|
import dayjs from 'dayjs';
|
|
@@ -691,14 +692,40 @@ export async function TemplateStoresList( req, res ) {
|
|
|
691
692
|
},
|
|
692
693
|
{
|
|
693
694
|
$group: {
|
|
694
|
-
_id: '$storeId',
|
|
695
|
+
_id: { store: '$storeId', floor: '$floorId' },
|
|
695
696
|
storeName: { $first: '$storeName' },
|
|
696
697
|
planoId: { $first: '$planoId' },
|
|
697
698
|
storeId: { $first: '$storeId' },
|
|
698
699
|
floorId: { $first: '$floorId' },
|
|
699
700
|
},
|
|
700
701
|
},
|
|
701
|
-
|
|
702
|
+
{
|
|
703
|
+
$lookup: {
|
|
704
|
+
from: 'storelayouts',
|
|
705
|
+
let: { floor: '$floorId' },
|
|
706
|
+
pipeline: [
|
|
707
|
+
{
|
|
708
|
+
$match: {
|
|
709
|
+
$expr: {
|
|
710
|
+
$eq: [ '$_id', '$$floor' ],
|
|
711
|
+
},
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
$project: {
|
|
716
|
+
floorName: 1,
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
],
|
|
720
|
+
as: 'floorDetails',
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
$unwind: {
|
|
725
|
+
path: '$floorDetails',
|
|
726
|
+
preserveNullAndEmptyArrays: true,
|
|
727
|
+
},
|
|
728
|
+
},
|
|
702
729
|
|
|
703
730
|
);
|
|
704
731
|
if ( inputData.showlookup ) {
|
|
@@ -727,6 +754,8 @@ export async function TemplateStoresList( req, res ) {
|
|
|
727
754
|
floorId: 1,
|
|
728
755
|
spocName: { $ifNull: [ '$storeData.spocDetails.name', '' ] },
|
|
729
756
|
spocEmail: { $ifNull: [ '$storeData.spocDetails.email', '' ] },
|
|
757
|
+
floorDetails: 1,
|
|
758
|
+
_id: '$_id.store',
|
|
730
759
|
},
|
|
731
760
|
},
|
|
732
761
|
);
|
|
@@ -787,8 +816,34 @@ export async function TemplateStoresList( req, res ) {
|
|
|
787
816
|
);
|
|
788
817
|
}
|
|
789
818
|
|
|
790
|
-
|
|
791
|
-
|
|
819
|
+
let floorQuery = [
|
|
820
|
+
{
|
|
821
|
+
$match: {
|
|
822
|
+
clientId: req.body.clientId,
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
$group: {
|
|
827
|
+
_id: '$storeId',
|
|
828
|
+
count: { $sum: 1 },
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
$match: {
|
|
833
|
+
count: { $gt: 1 },
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
$project: {
|
|
838
|
+
_id: 0,
|
|
839
|
+
store: '$_id',
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
];
|
|
843
|
+
const [ response, floorDetails ] = await Promise.all( [
|
|
844
|
+
storeFixtureService.aggregate( query ),
|
|
845
|
+
storeLayoutService.aggregate( floorQuery ),
|
|
846
|
+
] );
|
|
792
847
|
|
|
793
848
|
if ( !req.body.export && !response.length ) {
|
|
794
849
|
return res.sendError( 'No data found', 204 );
|
|
@@ -796,6 +851,7 @@ export async function TemplateStoresList( req, res ) {
|
|
|
796
851
|
let result = {
|
|
797
852
|
count: count.length || 0,
|
|
798
853
|
data: response || [],
|
|
854
|
+
doubleStore: floorDetails?.map( ( ele ) => ele.store ) ?? [],
|
|
799
855
|
};
|
|
800
856
|
if ( !req.body.export ) {
|
|
801
857
|
return res.sendSuccess( result );
|
|
@@ -1401,18 +1457,46 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1401
1457
|
},
|
|
1402
1458
|
{
|
|
1403
1459
|
$group: {
|
|
1404
|
-
_id: '$storeName',
|
|
1460
|
+
_id: { store: '$storeName', floor: '$floorId' },
|
|
1405
1461
|
storeId: { $first: '$storeId' },
|
|
1406
1462
|
updatedAt: { $first: '$updatedAt' },
|
|
1407
|
-
planoId: { $
|
|
1463
|
+
planoId: { $first: '$planoId' },
|
|
1408
1464
|
},
|
|
1409
1465
|
},
|
|
1410
1466
|
{
|
|
1411
1467
|
$project: {
|
|
1412
|
-
storeName: '$_id',
|
|
1468
|
+
storeName: '$_id.store',
|
|
1413
1469
|
storeId: 1,
|
|
1414
1470
|
updatedAt: 1,
|
|
1415
1471
|
planoId: 1,
|
|
1472
|
+
floorId: '$_id.floor',
|
|
1473
|
+
},
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
$lookup: {
|
|
1477
|
+
from: 'storelayouts',
|
|
1478
|
+
let: { floor: '$floorId' },
|
|
1479
|
+
pipeline: [
|
|
1480
|
+
{
|
|
1481
|
+
$match: {
|
|
1482
|
+
$expr: {
|
|
1483
|
+
$eq: [ '$_id', '$$floor' ],
|
|
1484
|
+
},
|
|
1485
|
+
},
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
$project: {
|
|
1489
|
+
floorName: 1,
|
|
1490
|
+
},
|
|
1491
|
+
},
|
|
1492
|
+
],
|
|
1493
|
+
as: 'floorDetails',
|
|
1494
|
+
},
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
$unwind: {
|
|
1498
|
+
path: '$floorDetails',
|
|
1499
|
+
preserveNullAndEmptyArrays: true,
|
|
1416
1500
|
},
|
|
1417
1501
|
},
|
|
1418
1502
|
{
|
|
@@ -1473,7 +1557,8 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1473
1557
|
planoId: 1,
|
|
1474
1558
|
storeDetails: { $ifNull: [ { $arrayElemAt: [ '$storeDetails.storeProfile', 0 ] }, {} ] },
|
|
1475
1559
|
clusterDetails: { $ifNull: [ { $arrayElemAt: [ '$clusterDetails.clusterName', 0 ] }, {} ] },
|
|
1476
|
-
|
|
1560
|
+
floorId: 1,
|
|
1561
|
+
floorName: { $ifNull: [ '$floorDetails.floorName', '' ] },
|
|
1477
1562
|
},
|
|
1478
1563
|
},
|
|
1479
1564
|
];
|
|
@@ -1501,14 +1586,36 @@ export async function getTemplateStoreList( req, res ) {
|
|
|
1501
1586
|
},
|
|
1502
1587
|
},
|
|
1503
1588
|
);
|
|
1504
|
-
|
|
1505
|
-
|
|
1589
|
+
let floorQuery = [
|
|
1590
|
+
{
|
|
1591
|
+
$group: {
|
|
1592
|
+
_id: '$storeId',
|
|
1593
|
+
count: { $sum: 1 },
|
|
1594
|
+
},
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
$match: {
|
|
1598
|
+
count: { $gt: 1 },
|
|
1599
|
+
},
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
$project: {
|
|
1603
|
+
_id: 0,
|
|
1604
|
+
store: '$_id',
|
|
1605
|
+
},
|
|
1606
|
+
},
|
|
1607
|
+
];
|
|
1608
|
+
const [ getStoreDetails, floorDetails ] = await Promise.all( [
|
|
1609
|
+
storeFixtureService.aggregate( query ),
|
|
1610
|
+
storeLayoutService.aggregate( floorQuery ),
|
|
1611
|
+
] );
|
|
1506
1612
|
if ( !getStoreDetails[0].data.length ) {
|
|
1507
1613
|
return res.sendError( 'No data found', 204 );
|
|
1508
1614
|
}
|
|
1509
1615
|
let result = {
|
|
1510
1616
|
count: getStoreDetails?.[0]?.count?.[0]?.total || 0,
|
|
1511
1617
|
data: getStoreDetails?.[0]?.data || [],
|
|
1618
|
+
doubleFloorStores: floorDetails?.map( ( ele ) => ele.store ) || [],
|
|
1512
1619
|
};
|
|
1513
1620
|
let status = templateDetails.isEdited ? 'Yet to publish' : 'Published';
|
|
1514
1621
|
result.data.forEach( ( ele ) => {
|
|
@@ -1155,10 +1155,12 @@ export async function getRolloutFeedbackv2( req, res ) {
|
|
|
1155
1155
|
}
|
|
1156
1156
|
response.vmRolloutData = await Promise.all( response.vmRolloutData.map( async ( ele ) => {
|
|
1157
1157
|
ele.storeFixtureList = await Promise.all( ele.storeFixtureList.map( async ( fixt ) => {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1158
|
+
if ( fixt?.FixtureData?.vmConfig?.length ) {
|
|
1159
|
+
fixt.FixtureData.vmConfig = await Promise.all( fixt?.FixtureData?.vmConfig?.map( async ( config ) => {
|
|
1160
|
+
let vmDetails = await planoVmService.findOne( { _id: config.vmId }, { vmType: 1, vmName: 1 } );
|
|
1161
|
+
return { ...config, vmType: vmDetails.vmType, vmName: vmDetails.vmName };
|
|
1162
|
+
} ) );
|
|
1163
|
+
}
|
|
1162
1164
|
return fixt;
|
|
1163
1165
|
} ) );
|
|
1164
1166
|
return ele;
|
|
@@ -1305,7 +1307,8 @@ function pipelineStage( type, planoId, floorId, filterByStatus, filterByApproval
|
|
|
1305
1307
|
},
|
|
1306
1308
|
],
|
|
1307
1309
|
},
|
|
1308
|
-
|
|
1310
|
+
{ $ne: [ { $ifNull: [ '$FixtureData.fixtureName', null ] }, null ] },
|
|
1311
|
+
// { $gt: [ { $size: { $ifNull: [ '$FixtureData' ] } }, 0 ] },
|
|
1309
1312
|
// { $gt: [ { $size: { $ifNull: [ '$FixtureData.shelfConfig', [] ] } }, 0 ] },
|
|
1310
1313
|
],
|
|
1311
1314
|
},
|
|
@@ -2657,7 +2657,7 @@ export async function storeFixturesv2( req, res ) {
|
|
|
2657
2657
|
const storeLayout = await Promise.all(
|
|
2658
2658
|
planograms.map( async ( planogram ) => {
|
|
2659
2659
|
const floors = await storeBuilderService.find(
|
|
2660
|
-
{ planoId: planogram._id },
|
|
2660
|
+
{ planoId: planogram._id, ...( req.body?.floorId && { _id: req.body.floorId } ) },
|
|
2661
2661
|
{ floorName: 1, layoutPolygon: 1, planoId: 1, isEdited: 1, planoProgress: 1 },
|
|
2662
2662
|
);
|
|
2663
2663
|
|
|
@@ -5011,33 +5011,50 @@ export async function getRolloutDetails( req, res ) {
|
|
|
5011
5011
|
const orCondition = [];
|
|
5012
5012
|
|
|
5013
5013
|
if ( req.body.filter.status.includes( 'yetToAssign' ) ) {
|
|
5014
|
-
orCondition.push(
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5014
|
+
orCondition.push(
|
|
5015
|
+
{
|
|
5016
|
+
$or: [
|
|
5017
|
+
{
|
|
5018
|
+
$and: [
|
|
5019
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
5020
|
+
{ merchEditedCount: { $ne: 0 } },
|
|
5021
|
+
],
|
|
5022
|
+
},
|
|
5023
|
+
{
|
|
5024
|
+
$and: [
|
|
5025
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
5026
|
+
{ vmEditedCount: { $ne: 0 } },
|
|
5027
|
+
],
|
|
5028
|
+
},
|
|
5029
|
+
{
|
|
5030
|
+
$expr: {
|
|
5031
|
+
$lt: [ { $size: '$taskDetails' }, 2 ],
|
|
5032
|
+
},
|
|
5033
|
+
},
|
|
5034
|
+
],
|
|
5035
|
+
},
|
|
5036
|
+
{
|
|
5037
|
+
$and: [
|
|
5038
|
+
{ taskDetails: { $elemMatch: { type: 'merchRollout', status: 'submit' } } },
|
|
5039
|
+
{ $or: [
|
|
5040
|
+
{ 'taskFeedback.fixtureStatus': 'disagree' },
|
|
5041
|
+
{ $and: [ { merchEditedCount: { $ne: 0 } }, { $expr: {
|
|
5042
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
5043
|
+
} } ] },
|
|
5044
|
+
] },
|
|
5045
|
+
],
|
|
5046
|
+
},
|
|
5047
|
+
{
|
|
5048
|
+
$and: [
|
|
5049
|
+
{ taskDetails: { $elemMatch: { type: 'vmRollout', status: 'submit' } } },
|
|
5050
|
+
{ $or: [
|
|
5051
|
+
{ 'taskFeedback.vmStatus': 'disagree' },
|
|
5052
|
+
{ $and: [ { vmEditedCount: { $ne: 0 } }, { $expr: {
|
|
5053
|
+
$eq: [ { $size: { $objectToArray: '$taskFeedback' } }, 0 ],
|
|
5054
|
+
} } ] },
|
|
5055
|
+
] },
|
|
5056
|
+
],
|
|
5057
|
+
},
|
|
5041
5058
|
);
|
|
5042
5059
|
}
|
|
5043
5060
|
|
|
@@ -5250,7 +5267,6 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5250
5267
|
taskId: { $last: '$_id' },
|
|
5251
5268
|
redoStatus: { $last: '$redoStatus' },
|
|
5252
5269
|
scheduleEndTime_iso: { $last: '$scheduleEndTime_iso' },
|
|
5253
|
-
taskId: { $last: '$_id' },
|
|
5254
5270
|
},
|
|
5255
5271
|
},
|
|
5256
5272
|
{
|
|
@@ -5271,287 +5287,45 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5271
5287
|
id: '$taskId',
|
|
5272
5288
|
breach: {
|
|
5273
5289
|
$cond: {
|
|
5274
|
-
if: {
|
|
5275
|
-
$gte: [ '$scheduleEndTime_iso', new Date() ],
|
|
5276
|
-
},
|
|
5290
|
+
if: { $gte: [ '$scheduleEndTime_iso', new Date() ] },
|
|
5277
5291
|
then: false,
|
|
5278
5292
|
else: true,
|
|
5279
5293
|
},
|
|
5280
5294
|
},
|
|
5281
5295
|
},
|
|
5282
5296
|
},
|
|
5283
|
-
taskIds: { $push: '$taskId' },
|
|
5284
5297
|
},
|
|
5285
5298
|
},
|
|
5299
|
+
// 🔹 Break out each task for lookup
|
|
5300
|
+
{ $unwind: '$taskStatus' },
|
|
5286
5301
|
{
|
|
5287
5302
|
$lookup: {
|
|
5288
5303
|
from: 'planotaskcompliances',
|
|
5289
5304
|
let: {
|
|
5290
|
-
task: '$
|
|
5305
|
+
task: '$taskStatus.id',
|
|
5306
|
+
type: '$taskStatus.type',
|
|
5291
5307
|
},
|
|
5292
5308
|
pipeline: [
|
|
5293
5309
|
{
|
|
5294
5310
|
$match: {
|
|
5295
5311
|
$expr: {
|
|
5296
5312
|
$and: [
|
|
5297
|
-
{ $eq: [ '$
|
|
5298
|
-
{ $eq: [ '$
|
|
5299
|
-
{ $in: [ '$taskId', '$$task' ] },
|
|
5300
|
-
// { $eq: [ '$status', 'incomplete' ] },
|
|
5301
|
-
{ $in: [ '$type', [ 'merchRollout', 'vmRollout' ] ] },
|
|
5313
|
+
{ $eq: [ '$taskId', '$$task' ] },
|
|
5314
|
+
{ $eq: [ '$type', '$$type' ] },
|
|
5302
5315
|
],
|
|
5303
5316
|
},
|
|
5304
5317
|
},
|
|
5305
5318
|
},
|
|
5306
5319
|
{ $sort: { _id: -1 } },
|
|
5307
|
-
{
|
|
5308
|
-
$set: {
|
|
5309
|
-
hasCompletedAnswers: {
|
|
5310
|
-
$anyElementTrue: {
|
|
5311
|
-
$map: {
|
|
5312
|
-
input: '$answers',
|
|
5313
|
-
as: 'ans',
|
|
5314
|
-
in: { $eq: [ '$$ans.status', null ] },
|
|
5315
|
-
},
|
|
5316
|
-
},
|
|
5317
|
-
},
|
|
5318
|
-
hasPendingIssues: {
|
|
5319
|
-
$anyElementTrue: {
|
|
5320
|
-
$map: {
|
|
5321
|
-
input: {
|
|
5322
|
-
$concatArrays: [
|
|
5323
|
-
{
|
|
5324
|
-
$reduce: {
|
|
5325
|
-
input: '$answers',
|
|
5326
|
-
initialValue: [],
|
|
5327
|
-
in: {
|
|
5328
|
-
$concatArrays: [
|
|
5329
|
-
'$$value',
|
|
5330
|
-
{
|
|
5331
|
-
$reduce: {
|
|
5332
|
-
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
5333
|
-
initialValue: [],
|
|
5334
|
-
in: {
|
|
5335
|
-
$concatArrays: [
|
|
5336
|
-
'$$value',
|
|
5337
|
-
{ $ifNull: [ '$$this.Details', [] ] },
|
|
5338
|
-
],
|
|
5339
|
-
},
|
|
5340
|
-
},
|
|
5341
|
-
},
|
|
5342
|
-
],
|
|
5343
|
-
},
|
|
5344
|
-
},
|
|
5345
|
-
},
|
|
5346
|
-
],
|
|
5347
|
-
},
|
|
5348
|
-
as: 'detail',
|
|
5349
|
-
in: {
|
|
5350
|
-
$or: [ { $eq: [ '$$detail.status', 'pending' ] } ],
|
|
5351
|
-
},
|
|
5352
|
-
},
|
|
5353
|
-
},
|
|
5354
|
-
},
|
|
5355
|
-
hasDisagreeIssues: {
|
|
5356
|
-
$anyElementTrue: {
|
|
5357
|
-
$map: {
|
|
5358
|
-
input: {
|
|
5359
|
-
$concatArrays: [
|
|
5360
|
-
'$answers',
|
|
5361
|
-
{
|
|
5362
|
-
$reduce: {
|
|
5363
|
-
input: '$answers',
|
|
5364
|
-
initialValue: [],
|
|
5365
|
-
in: {
|
|
5366
|
-
$concatArrays: [
|
|
5367
|
-
'$$value',
|
|
5368
|
-
{
|
|
5369
|
-
$reduce: {
|
|
5370
|
-
input: { $ifNull: [ '$$this.issues', [] ] },
|
|
5371
|
-
initialValue: [],
|
|
5372
|
-
in: {
|
|
5373
|
-
$concatArrays: [
|
|
5374
|
-
'$$value',
|
|
5375
|
-
{ $ifNull: [ '$$this.Details', [] ] },
|
|
5376
|
-
],
|
|
5377
|
-
},
|
|
5378
|
-
},
|
|
5379
|
-
},
|
|
5380
|
-
],
|
|
5381
|
-
},
|
|
5382
|
-
},
|
|
5383
|
-
},
|
|
5384
|
-
],
|
|
5385
|
-
},
|
|
5386
|
-
as: 'detail',
|
|
5387
|
-
in: {
|
|
5388
|
-
$or: [ { $eq: [ '$$detail.status', 'disagree' ] } ],
|
|
5389
|
-
},
|
|
5390
|
-
},
|
|
5391
|
-
},
|
|
5392
|
-
},
|
|
5393
|
-
},
|
|
5394
|
-
},
|
|
5395
|
-
{
|
|
5396
|
-
$group: {
|
|
5397
|
-
_id: { taskId: '$taskId' },
|
|
5398
|
-
|
|
5399
|
-
// merch counters
|
|
5400
|
-
merchDisagree: {
|
|
5401
|
-
$sum: {
|
|
5402
|
-
$cond: [
|
|
5403
|
-
{ $and: [ { $eq: [ '$type', 'merchRollout' ] }, '$hasDisagreeIssues' ] },
|
|
5404
|
-
1,
|
|
5405
|
-
0,
|
|
5406
|
-
],
|
|
5407
|
-
},
|
|
5408
|
-
},
|
|
5409
|
-
merchPending: {
|
|
5410
|
-
$sum: {
|
|
5411
|
-
$cond: [
|
|
5412
|
-
{
|
|
5413
|
-
$and: [
|
|
5414
|
-
{ $eq: [ '$type', 'merchRollout' ] },
|
|
5415
|
-
{ $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
|
|
5416
|
-
],
|
|
5417
|
-
},
|
|
5418
|
-
1,
|
|
5419
|
-
0,
|
|
5420
|
-
],
|
|
5421
|
-
},
|
|
5422
|
-
},
|
|
5423
|
-
merchApproved: {
|
|
5424
|
-
$push: {
|
|
5425
|
-
$cond: [
|
|
5426
|
-
{
|
|
5427
|
-
$and: [
|
|
5428
|
-
{ $eq: [ '$type', 'merchRollout' ] },
|
|
5429
|
-
{ $eq: [ '$approvalStatus', 'approved' ] },
|
|
5430
|
-
],
|
|
5431
|
-
},
|
|
5432
|
-
'$approvalStatus',
|
|
5433
|
-
'$$REMOVE',
|
|
5434
|
-
],
|
|
5435
|
-
},
|
|
5436
|
-
},
|
|
5437
|
-
|
|
5438
|
-
// vm counters
|
|
5439
|
-
vmDisagree: {
|
|
5440
|
-
$sum: {
|
|
5441
|
-
$cond: [
|
|
5442
|
-
{ $and: [ { $eq: [ '$type', 'vmRollout' ] }, '$hasDisagreeIssues' ] },
|
|
5443
|
-
1,
|
|
5444
|
-
0,
|
|
5445
|
-
],
|
|
5446
|
-
},
|
|
5447
|
-
},
|
|
5448
|
-
vmPending: {
|
|
5449
|
-
$sum: {
|
|
5450
|
-
$cond: [
|
|
5451
|
-
{
|
|
5452
|
-
$and: [
|
|
5453
|
-
{ $eq: [ '$type', 'vmRollout' ] },
|
|
5454
|
-
{ $or: [ '$hasPendingIssues', '$hasCompletedAnswers' ] },
|
|
5455
|
-
],
|
|
5456
|
-
},
|
|
5457
|
-
1,
|
|
5458
|
-
0,
|
|
5459
|
-
],
|
|
5460
|
-
},
|
|
5461
|
-
},
|
|
5462
|
-
vmApproved: {
|
|
5463
|
-
$push: {
|
|
5464
|
-
$cond: [
|
|
5465
|
-
{
|
|
5466
|
-
$and: [
|
|
5467
|
-
{ $eq: [ '$type', 'vmRollout' ] },
|
|
5468
|
-
{ $eq: [ '$approvalStatus', 'approved' ] },
|
|
5469
|
-
],
|
|
5470
|
-
},
|
|
5471
|
-
'$approvalStatus',
|
|
5472
|
-
'$$REMOVE',
|
|
5473
|
-
],
|
|
5474
|
-
},
|
|
5475
|
-
},
|
|
5476
|
-
|
|
5477
|
-
// counts
|
|
5478
|
-
merchCount: {
|
|
5479
|
-
$sum: {
|
|
5480
|
-
$cond: [ { $eq: [ '$type', 'merchRollout' ] }, 1, 0 ],
|
|
5481
|
-
},
|
|
5482
|
-
},
|
|
5483
|
-
vmCount: {
|
|
5484
|
-
$sum: {
|
|
5485
|
-
$cond: [ { $eq: [ '$type', 'vmRollout' ] }, 1, 0 ],
|
|
5486
|
-
},
|
|
5487
|
-
},
|
|
5488
|
-
},
|
|
5489
|
-
},
|
|
5490
|
-
{
|
|
5491
|
-
$project: {
|
|
5492
|
-
_id: 0,
|
|
5493
|
-
merchStatus: {
|
|
5494
|
-
$switch: {
|
|
5495
|
-
branches: [
|
|
5496
|
-
{
|
|
5497
|
-
case: { $eq: [ '$merchCount', 0 ] },
|
|
5498
|
-
then: '',
|
|
5499
|
-
},
|
|
5500
|
-
{
|
|
5501
|
-
case: { $gt: [ '$merchPending', 0 ] },
|
|
5502
|
-
then: 'pending',
|
|
5503
|
-
},
|
|
5504
|
-
{
|
|
5505
|
-
case: { $gt: [ '$merchDisagree', 0 ] },
|
|
5506
|
-
then: 'disagree',
|
|
5507
|
-
},
|
|
5508
|
-
{
|
|
5509
|
-
case: {
|
|
5510
|
-
$and: [
|
|
5511
|
-
{ $eq: [ '$merchPending', 0 ] },
|
|
5512
|
-
{ $eq: [ '$merchDisagree', 0 ] },
|
|
5513
|
-
{ $eq: [ { $size: '$merchApproved' }, '$merchCount' ] },
|
|
5514
|
-
],
|
|
5515
|
-
},
|
|
5516
|
-
then: 'complete',
|
|
5517
|
-
},
|
|
5518
|
-
],
|
|
5519
|
-
default: 'pending',
|
|
5520
|
-
},
|
|
5521
|
-
},
|
|
5522
|
-
vmStatus: {
|
|
5523
|
-
$switch: {
|
|
5524
|
-
branches: [
|
|
5525
|
-
{
|
|
5526
|
-
case: { $eq: [ '$vmCount', 0 ] },
|
|
5527
|
-
then: '',
|
|
5528
|
-
},
|
|
5529
|
-
{
|
|
5530
|
-
case: { $gt: [ '$vmPending', 0 ] },
|
|
5531
|
-
then: 'pending',
|
|
5532
|
-
},
|
|
5533
|
-
{
|
|
5534
|
-
case: { $gt: [ '$vmDisagree', 0 ] },
|
|
5535
|
-
then: 'disagree',
|
|
5536
|
-
},
|
|
5537
|
-
{
|
|
5538
|
-
case: {
|
|
5539
|
-
$and: [
|
|
5540
|
-
{ $eq: [ '$vmPending', 0 ] },
|
|
5541
|
-
{ $eq: [ '$vmDisagree', 0 ] },
|
|
5542
|
-
{ $eq: [ { $size: '$vmApproved' }, '$vmCount' ] },
|
|
5543
|
-
],
|
|
5544
|
-
},
|
|
5545
|
-
then: 'complete',
|
|
5546
|
-
},
|
|
5547
|
-
],
|
|
5548
|
-
default: 'pending',
|
|
5549
|
-
},
|
|
5550
|
-
},
|
|
5551
|
-
},
|
|
5552
|
-
},
|
|
5553
5320
|
],
|
|
5554
|
-
as: 'taskDetails',
|
|
5321
|
+
as: 'taskStatus.taskDetails', // ✅ correctly attaches inside taskStatus
|
|
5322
|
+
},
|
|
5323
|
+
},
|
|
5324
|
+
// 🔹 Group back into array
|
|
5325
|
+
{
|
|
5326
|
+
$group: {
|
|
5327
|
+
_id: null,
|
|
5328
|
+
taskStatus: { $push: '$taskStatus' },
|
|
5555
5329
|
},
|
|
5556
5330
|
},
|
|
5557
5331
|
{
|
|
@@ -5574,30 +5348,80 @@ export async function getRolloutTaskDetails( req, res ) {
|
|
|
5574
5348
|
createdAt: '$$task.createdAt',
|
|
5575
5349
|
userName: '$$task.userName',
|
|
5576
5350
|
submitTime_string: '$$task.submitTime_string',
|
|
5577
|
-
|
|
5578
|
-
$switch: {
|
|
5579
|
-
branches: [
|
|
5580
|
-
{
|
|
5581
|
-
case: { $eq: [ '$$task.type', 'merchRollout' ] },
|
|
5582
|
-
then: { $arrayElemAt: [ '$taskDetails.merchStatus', 0 ] },
|
|
5583
|
-
},
|
|
5584
|
-
{
|
|
5585
|
-
case: { $eq: [ '$$task.type', 'vmRollout' ] },
|
|
5586
|
-
then: { $arrayElemAt: [ '$taskDetails.vmStatus', 0 ] },
|
|
5587
|
-
},
|
|
5588
|
-
],
|
|
5589
|
-
default: '',
|
|
5590
|
-
},
|
|
5591
|
-
},
|
|
5351
|
+
taskDetails: '$$task.taskDetails', // ✅ fixed reference
|
|
5592
5352
|
},
|
|
5593
5353
|
},
|
|
5594
5354
|
},
|
|
5595
5355
|
},
|
|
5596
5356
|
},
|
|
5597
|
-
|
|
5598
5357
|
];
|
|
5599
5358
|
|
|
5359
|
+
|
|
5600
5360
|
let taskInfo = await planotaskService.aggregate( query );
|
|
5361
|
+
let vmRolloutStatus ='';
|
|
5362
|
+
let merchRolloutStatus = '';
|
|
5363
|
+
if ( taskInfo.length ) {
|
|
5364
|
+
let merchPendingCount = 0;
|
|
5365
|
+
let merchDisagreeCount = 0;
|
|
5366
|
+
let vmPendingCount = 0;
|
|
5367
|
+
let vmDisagreeCount = 0;
|
|
5368
|
+
taskInfo?.[0]?.taskStatus.forEach( ( task ) => {
|
|
5369
|
+
if ( task.status == 'submit' ) {
|
|
5370
|
+
if ( task.type == 'merchRollout' ) {
|
|
5371
|
+
task.taskDetails.forEach( ( ele ) => {
|
|
5372
|
+
if ( ele.status == 'complete' && !ele?.answers?.[0]?.issues.length ) {
|
|
5373
|
+
if ( !ele?.answers?.[0]?.status ) {
|
|
5374
|
+
merchPendingCount++;
|
|
5375
|
+
}
|
|
5376
|
+
if ( ele?.answers?.[0]?.status == 'disagree' ) {
|
|
5377
|
+
merchDisagreeCount++;
|
|
5378
|
+
}
|
|
5379
|
+
} else {
|
|
5380
|
+
ele?.answers.forEach( ( ans ) => {
|
|
5381
|
+
ans.issues.forEach( ( iss ) => {
|
|
5382
|
+
iss.Details.forEach( ( det ) => {
|
|
5383
|
+
if ( det.status == 'pending' ) {
|
|
5384
|
+
merchPendingCount++;
|
|
5385
|
+
}
|
|
5386
|
+
if ( det.status == 'disagree' ) {
|
|
5387
|
+
merchDisagreeCount++;
|
|
5388
|
+
}
|
|
5389
|
+
} );
|
|
5390
|
+
} );
|
|
5391
|
+
} );
|
|
5392
|
+
}
|
|
5393
|
+
} );
|
|
5394
|
+
merchRolloutStatus = merchPendingCount ? 'pending' : merchDisagreeCount ? 'disagree' : task.taskDetails?.length ? 'complete' : '';
|
|
5395
|
+
} else {
|
|
5396
|
+
task.taskDetails.forEach( ( ele ) => {
|
|
5397
|
+
if ( ele.status == 'complete' && !ele?.answers?.[0]?.issues.length ) {
|
|
5398
|
+
if ( !ele?.answers?.[0]?.status ) {
|
|
5399
|
+
vmPendingCount++;
|
|
5400
|
+
}
|
|
5401
|
+
if ( ele?.answers?.[0]?.status == 'disagree' ) {
|
|
5402
|
+
vmDisagreeCount++;
|
|
5403
|
+
}
|
|
5404
|
+
} else {
|
|
5405
|
+
ele?.answers.forEach( ( ans ) => {
|
|
5406
|
+
ans.issues.forEach( ( iss ) => {
|
|
5407
|
+
iss.Details.forEach( ( det ) => {
|
|
5408
|
+
if ( det.status == 'pending' ) {
|
|
5409
|
+
vmPendingCount++;
|
|
5410
|
+
}
|
|
5411
|
+
if ( det.status == 'disagree' ) {
|
|
5412
|
+
vmDisagreeCount++;
|
|
5413
|
+
}
|
|
5414
|
+
} );
|
|
5415
|
+
} );
|
|
5416
|
+
} );
|
|
5417
|
+
}
|
|
5418
|
+
} );
|
|
5419
|
+
vmRolloutStatus = vmPendingCount ? 'pending' : vmDisagreeCount ? 'disagree' : task.taskDetails?.length ? 'complete' : '';
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
task.feedbackStatus = task.type == 'vmRollout' ? vmRolloutStatus : merchRolloutStatus;
|
|
5423
|
+
} );
|
|
5424
|
+
}
|
|
5601
5425
|
const [ merchCount, vmCount ] = await Promise.all( [
|
|
5602
5426
|
await storeFixtureService.count( { floorId: req.query.floorId, isMerchEdited: true } ),
|
|
5603
5427
|
await storeFixtureService.count( { floorId: req.query.floorId, isVmEdited: true } ),
|
|
@@ -45,7 +45,9 @@ export const updateFloor = {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export const storeListSchema = joi.object( {
|
|
48
|
-
id: joi.array().items( joi.any() ).min( 1 ).
|
|
48
|
+
id: joi.array().items( joi.any() ).min( 1 ).optional(),
|
|
49
|
+
planoId: joi.string().optional(),
|
|
50
|
+
floorId: joi.string().optional(),
|
|
49
51
|
treeView: joi.boolean().optional(),
|
|
50
52
|
} );
|
|
51
53
|
|