tango-app-api-store-builder 1.0.0-beta-86 → 1.0.0-beta-88
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.
|
@@ -380,8 +380,8 @@ export async function getTaskDetails( req, res ) {
|
|
|
380
380
|
if ( !req.query.storeId ) {
|
|
381
381
|
return res.sendError( 'Store id is required', 400 );
|
|
382
382
|
}
|
|
383
|
-
let date = req.query?.date || dayjs().format( 'YYYY-MM-DD' );
|
|
384
|
-
let getDetails = await processedService.find( { store_id: req.query.storeId, date_string: date, isPlano: true, checklistStatus: { $ne: 'submit' }, userId: req.user._id }, { checkListName: 1, taskType: '$planoType', checklistStatus: 1 } );
|
|
383
|
+
// let date = req.query?.date || dayjs().format( 'YYYY-MM-DD' );
|
|
384
|
+
// let getDetails = await processedService.find( { store_id: req.query.storeId, date_string: date, isPlano: true, checklistStatus: { $ne: 'submit' }, userId: req.user._id }, { checkListName: 1, taskType: '$planoType', checklistStatus: 1 } );
|
|
385
385
|
return res.sendSuccess( [] );
|
|
386
386
|
} catch ( e ) {
|
|
387
387
|
logger.error( { functionName: 'getTaskDetails', error: e } );
|
|
@@ -493,6 +493,9 @@ export async function updateAnswers( req, res ) {
|
|
|
493
493
|
}
|
|
494
494
|
} );
|
|
495
495
|
|
|
496
|
+
let taskDetails = await processedService.findOne( { date_string: dayjs().format( 'YYYY-MM-DD' ), userId: req.user._id, isPlano: true, planoType: 'layout' } );
|
|
497
|
+
|
|
498
|
+
|
|
496
499
|
let data = {
|
|
497
500
|
fixtureId: req.body.fixtureId,
|
|
498
501
|
answers: req.body.answers,
|
|
@@ -500,9 +503,12 @@ export async function updateAnswers( req, res ) {
|
|
|
500
503
|
planoId: req.body.planoId,
|
|
501
504
|
floorId: req.body.floorId,
|
|
502
505
|
type: req.body.type,
|
|
506
|
+
date_iso: new Date( dayjs().format( 'YYYY-MM-DD' ) ),
|
|
507
|
+
taskId: taskDetails?._id,
|
|
508
|
+
storeName: taskDetails?.storeName,
|
|
503
509
|
};
|
|
504
510
|
|
|
505
|
-
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ) }, data );
|
|
511
|
+
await planoTaskService.updateOne( { planoId: req.body.planoId, floorId: req.body.floorId, fixtureId: req.body.fixtureId, type: req.body.type, date_string: dayjs().format( 'YYYY-MM-DD' ), ...( taskDetails?._id ) ? { taskId: taskDetails?._id } :{} }, data );
|
|
506
512
|
return res.sendSuccess( 'Fixture details updated successfully' );
|
|
507
513
|
} catch ( e ) {
|
|
508
514
|
logger.error( { functionName: 'updateAnswers', error: e } );
|
|
@@ -618,12 +624,14 @@ export async function generatetaskDetails( req, res ) {
|
|
|
618
624
|
$match: {
|
|
619
625
|
date_iso: { $gte: new Date( req.body.fromDate ), $lte: new Date( req.body.toDate ) },
|
|
620
626
|
isPlano: true,
|
|
627
|
+
planoType: 'layout',
|
|
621
628
|
},
|
|
622
629
|
},
|
|
623
630
|
{
|
|
624
631
|
$project: {
|
|
625
632
|
_id: 0,
|
|
626
633
|
storeName: 1,
|
|
634
|
+
store_id: 1,
|
|
627
635
|
userEmail: 1,
|
|
628
636
|
planoId: 1,
|
|
629
637
|
checklistStatus: 1,
|
|
@@ -638,8 +646,24 @@ export async function generatetaskDetails( req, res ) {
|
|
|
638
646
|
},
|
|
639
647
|
},
|
|
640
648
|
},
|
|
649
|
+
{
|
|
650
|
+
$group: {
|
|
651
|
+
_id: '$store_id',
|
|
652
|
+
count: { $sum: 1 },
|
|
653
|
+
storeName: { $first: '$storeName' },
|
|
654
|
+
checklistStatus: { $push: '$checklistStatus' },
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
$project: {
|
|
659
|
+
_id: 0,
|
|
660
|
+
storeName: 1,
|
|
661
|
+
checklistStatus: 1,
|
|
662
|
+
count: 1,
|
|
663
|
+
},
|
|
664
|
+
},
|
|
641
665
|
];
|
|
642
|
-
|
|
666
|
+
console.log( JSON.stringify( query ) );
|
|
643
667
|
let taskDetails = await processedService.aggregate( query );
|
|
644
668
|
let processedTaskDetails = await planoTaskService.find( { date_string: { $gte: req.body.fromDate, $lte: req.body.toDate }, type: 'layout', status: 'incomplete' } );
|
|
645
669
|
processedTaskDetails.forEach( ( item ) => {
|
|
@@ -652,11 +676,21 @@ export async function generatetaskDetails( req, res ) {
|
|
|
652
676
|
taskDetails.forEach( ( ele ) => {
|
|
653
677
|
delete ele.planoId;
|
|
654
678
|
} );
|
|
679
|
+
// console.log( taskDetails );
|
|
680
|
+
// let completeStore = [ ...new Set( taskDetails.filter( ( ele ) => ele.checklistStatus.includes( 'submit' ) ).map( ( ele ) => ele.storeName ) ) ];
|
|
681
|
+
|
|
682
|
+
// let incompleteStore = [ ...new Set( taskDetails.filter( ( ele ) => !ele.checklistStatus.includes( 'submit' ) ).map( ( ele ) => {
|
|
683
|
+
// return { storeName: ele.storeName, checklistStatus: ele.checklistStatus[ele.checklistStatus.length-1] };
|
|
684
|
+
// } ) ) ];
|
|
685
|
+
|
|
686
|
+
// incompleteStore = incompleteStore.filter( ( ele ) => !completeStore.includes( ele ) );
|
|
655
687
|
|
|
656
688
|
if ( !taskDetails.length ) {
|
|
657
689
|
return res.sendError( 'No date found', 204 );
|
|
658
690
|
}
|
|
659
691
|
|
|
692
|
+
// return res.sendSuccess( { completeCount: completeStore.length, store: completeStore, incompleteStore: incompleteStore, incompleteStoreCount: incompleteStore.length } );
|
|
693
|
+
|
|
660
694
|
await download( taskDetails, res );
|
|
661
695
|
} catch ( e ) {
|
|
662
696
|
logger.error( { functioName: 'generatetaskDetails', error: e } );
|
|
@@ -708,11 +742,32 @@ export async function taskSubmitDetails( req, res ) {
|
|
|
708
742
|
floorId: 1,
|
|
709
743
|
},
|
|
710
744
|
},
|
|
745
|
+
{
|
|
746
|
+
$group: {
|
|
747
|
+
_id: '$planoId',
|
|
748
|
+
storeName: { $first: '$storeName' },
|
|
749
|
+
answers: { $last: '$answers' },
|
|
750
|
+
type: { $last: '$type' },
|
|
751
|
+
status: { $last: '$status' },
|
|
752
|
+
floorId: { $last: '$floorId' },
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
$project: {
|
|
757
|
+
storeName: 1,
|
|
758
|
+
answers: 1,
|
|
759
|
+
type: 1,
|
|
760
|
+
status: 1,
|
|
761
|
+
planoId: '$_id',
|
|
762
|
+
floorId: 1,
|
|
763
|
+
},
|
|
764
|
+
},
|
|
711
765
|
];
|
|
712
766
|
|
|
713
767
|
let processedTaskDetails = await planoTaskService.aggregate( query );
|
|
714
768
|
let completeStore = [ ...new Set( processedTaskDetails.filter( ( ele ) => ele.status == 'complete' ).map( ( ele ) => ele.storeName ) ) ];
|
|
715
769
|
let incompleteStore = [ ...new Set( processedTaskDetails.filter( ( ele ) => ele.status == 'incomplete' ).map( ( ele ) => ele.storeName ) ) ];
|
|
770
|
+
incompleteStore = incompleteStore.filter( ( ele ) => !completeStore.includes( ele ) );
|
|
716
771
|
return res.sendSuccess( { complete: { count: completeStore.length, storeList: completeStore }, incompleteStore: { count: incompleteStore.length, storeList: incompleteStore }, data: processedTaskDetails } );
|
|
717
772
|
} catch ( e ) {
|
|
718
773
|
logger.error( { functioName: 'taskSubmitDetails', error: e } );
|
|
@@ -23,6 +23,9 @@ scriptRouter
|
|
|
23
23
|
.post( '/getVmTaskData', scriptController.getVmTaskData )
|
|
24
24
|
.post( '/updateVmData', scriptController.updateVmData )
|
|
25
25
|
.post( '/createCrestPlanogram', scriptController.createCrestPlanogram )
|
|
26
|
+
.post( '/updateCrestPlanogram', scriptController.updateCrestPlanogram )
|
|
26
27
|
.post( '/updatelayout', scriptController.updatelayout )
|
|
27
28
|
.post( '/updateCrestVms', scriptController.updateCrestVms )
|
|
28
|
-
.post( '/downloadPlanoImages', scriptController.downloadPlanoImage )
|
|
29
|
+
.post( '/downloadPlanoImages', scriptController.downloadPlanoImage )
|
|
30
|
+
.post( '/getVideoUrls', scriptController.getVideoLinks )
|
|
31
|
+
.post( '/updateExcelPlanogram', scriptController.updateExcelPlanogram );
|