tango-app-api-infra 3.0.56-dev → 3.0.57-dev
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
|
+
import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
|
|
5
5
|
import { updateOneStore, findStore } from '../services/store.service.js';
|
|
6
6
|
import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, appConfig, getUTC } from 'tango-app-api-middleware';
|
|
@@ -652,6 +652,7 @@ export async function infraTable( req, res ) {
|
|
|
652
652
|
status: 1,
|
|
653
653
|
createdAt: 1,
|
|
654
654
|
issueDate: 1,
|
|
655
|
+
addressingUser: { $toObjectId: '$ticketDetails.addressingUser' },
|
|
655
656
|
primaryIssue: {
|
|
656
657
|
$filter: {
|
|
657
658
|
input: '$ticketActivity',
|
|
@@ -683,6 +684,7 @@ export async function infraTable( req, res ) {
|
|
|
683
684
|
storeName: 1,
|
|
684
685
|
clientName: 1,
|
|
685
686
|
createdAt: 1,
|
|
687
|
+
addressingUser: 1,
|
|
686
688
|
ticketId: 1,
|
|
687
689
|
issueDate: { $ifNull: [ '$issueDate', '' ] },
|
|
688
690
|
status: 1,
|
|
@@ -690,6 +692,36 @@ export async function infraTable( req, res ) {
|
|
|
690
692
|
secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
|
|
691
693
|
},
|
|
692
694
|
},
|
|
695
|
+
{
|
|
696
|
+
'$lookup': {
|
|
697
|
+
'from': 'users',
|
|
698
|
+
'let': { 'userId': '$addressingUser' },
|
|
699
|
+
'pipeline': [
|
|
700
|
+
{
|
|
701
|
+
'$match': {
|
|
702
|
+
'$expr': {
|
|
703
|
+
'$eq': [ '$_id', '$$userId' ],
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
'$project': {
|
|
709
|
+
'userName': 1,
|
|
710
|
+
'email': 1,
|
|
711
|
+
'role': 1,
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
],
|
|
715
|
+
'as': 'user',
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
|
|
719
|
+
{
|
|
720
|
+
$unwind: {
|
|
721
|
+
path: '$user',
|
|
722
|
+
preserveNullAndEmptyArrays: true,
|
|
723
|
+
},
|
|
724
|
+
},
|
|
693
725
|
{
|
|
694
726
|
$group: {
|
|
695
727
|
_id: '$ticketId',
|
|
@@ -697,6 +729,8 @@ export async function infraTable( req, res ) {
|
|
|
697
729
|
clientId: { $first: '$clientId' },
|
|
698
730
|
ticketId: { $first: '$ticketId' },
|
|
699
731
|
storeName: { $first: '$storeName' },
|
|
732
|
+
userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
|
|
733
|
+
userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
|
|
700
734
|
clientName: { $first: '$clientName' },
|
|
701
735
|
createdAt: { $first: '$createdAt' },
|
|
702
736
|
issueDate: { $last: '$issueDate' },
|
|
@@ -704,19 +738,34 @@ export async function infraTable( req, res ) {
|
|
|
704
738
|
primaryIssue: { $last: '$primaryIssue' },
|
|
705
739
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
706
740
|
},
|
|
707
|
-
}
|
|
741
|
+
},
|
|
742
|
+
);
|
|
708
743
|
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
709
744
|
query.push( {
|
|
710
745
|
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
711
746
|
} );
|
|
712
747
|
}
|
|
713
|
-
if ( req.body.storeIdFilter && req.body.storeIdFilter.length>0 ) {
|
|
748
|
+
if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
|
|
714
749
|
query.push( {
|
|
715
750
|
$match: {
|
|
716
751
|
storeId: { $in: req.body.storeIdFilter },
|
|
717
752
|
},
|
|
718
753
|
} );
|
|
719
754
|
}
|
|
755
|
+
if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
|
|
756
|
+
query.push( {
|
|
757
|
+
$match: {
|
|
758
|
+
status: { $in: req.body.statusFilter },
|
|
759
|
+
},
|
|
760
|
+
} );
|
|
761
|
+
}
|
|
762
|
+
if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
|
|
763
|
+
query.push( {
|
|
764
|
+
$match: {
|
|
765
|
+
userEmail: { $in: req.body.userFilter },
|
|
766
|
+
},
|
|
767
|
+
} );
|
|
768
|
+
}
|
|
720
769
|
let ticketList = await aggregateTangoTicket( query );
|
|
721
770
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
722
771
|
const categoryCounts = {};
|
|
@@ -816,7 +865,8 @@ export async function installationTable( req, res ) {
|
|
|
816
865
|
{ createdAt: { $lte: date.end } },
|
|
817
866
|
],
|
|
818
867
|
},
|
|
819
|
-
},
|
|
868
|
+
},
|
|
869
|
+
{
|
|
820
870
|
$project: {
|
|
821
871
|
storeId: '$basicDetails.storeId',
|
|
822
872
|
clientId: '$basicDetails.clientId',
|
|
@@ -825,6 +875,7 @@ export async function installationTable( req, res ) {
|
|
|
825
875
|
clientName: '$basicDetails.clientName',
|
|
826
876
|
status: 1,
|
|
827
877
|
createdAt: 1,
|
|
878
|
+
addressingUser: '$ticketDetails.addressingUser',
|
|
828
879
|
installationStatus: '$ticketDetails.installationStatus',
|
|
829
880
|
issueDate: 1,
|
|
830
881
|
primaryIssue: {
|
|
@@ -859,6 +910,7 @@ export async function installationTable( req, res ) {
|
|
|
859
910
|
clientName: 1,
|
|
860
911
|
createdAt: 1,
|
|
861
912
|
ticketId: 1,
|
|
913
|
+
addressingUser: 1,
|
|
862
914
|
installationStatus: 1,
|
|
863
915
|
issueDate: { $ifNull: [ '$issueDate', '' ] },
|
|
864
916
|
status: 1,
|
|
@@ -866,6 +918,36 @@ export async function installationTable( req, res ) {
|
|
|
866
918
|
secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
|
|
867
919
|
},
|
|
868
920
|
},
|
|
921
|
+
{
|
|
922
|
+
'$lookup': {
|
|
923
|
+
'from': 'users',
|
|
924
|
+
'let': { 'userId': '$addressingUser' },
|
|
925
|
+
'pipeline': [
|
|
926
|
+
{
|
|
927
|
+
'$match': {
|
|
928
|
+
'$expr': {
|
|
929
|
+
'$eq': [ '$_id', '$$userId' ],
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
'$project': {
|
|
935
|
+
'userName': 1,
|
|
936
|
+
'email': 1,
|
|
937
|
+
'role': 1,
|
|
938
|
+
},
|
|
939
|
+
},
|
|
940
|
+
],
|
|
941
|
+
'as': 'user',
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
|
|
945
|
+
{
|
|
946
|
+
$unwind: {
|
|
947
|
+
path: '$user',
|
|
948
|
+
preserveNullAndEmptyArrays: true,
|
|
949
|
+
},
|
|
950
|
+
},
|
|
869
951
|
{
|
|
870
952
|
$group: {
|
|
871
953
|
_id: '$ticketId',
|
|
@@ -873,6 +955,8 @@ export async function installationTable( req, res ) {
|
|
|
873
955
|
clientId: { $first: '$clientId' },
|
|
874
956
|
ticketId: { $first: '$ticketId' },
|
|
875
957
|
storeName: { $first: '$storeName' },
|
|
958
|
+
userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
|
|
959
|
+
userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
|
|
876
960
|
clientName: { $first: '$clientName' },
|
|
877
961
|
createdAt: { $first: '$createdAt' },
|
|
878
962
|
issueDate: { $last: '$issueDate' },
|
|
@@ -881,12 +965,34 @@ export async function installationTable( req, res ) {
|
|
|
881
965
|
primaryIssue: { $last: '$primaryIssue' },
|
|
882
966
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
883
967
|
},
|
|
884
|
-
}
|
|
968
|
+
},
|
|
969
|
+
);
|
|
885
970
|
if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
|
|
886
971
|
query.push( {
|
|
887
972
|
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
888
973
|
} );
|
|
889
974
|
}
|
|
975
|
+
if ( req.body.storeIdFilter && req.body.storeIdFilter.length > 0 ) {
|
|
976
|
+
query.push( {
|
|
977
|
+
$match: {
|
|
978
|
+
storeId: { $in: req.body.storeIdFilter },
|
|
979
|
+
},
|
|
980
|
+
} );
|
|
981
|
+
}
|
|
982
|
+
if ( req.body.statusFilter && req.body.statusFilter.length > 0 ) {
|
|
983
|
+
query.push( {
|
|
984
|
+
$match: {
|
|
985
|
+
installationStatus: { $in: req.body.statusFilter },
|
|
986
|
+
},
|
|
987
|
+
} );
|
|
988
|
+
}
|
|
989
|
+
if ( req.body.userFilter && req.body.userFilter.length > 0 ) {
|
|
990
|
+
query.push( {
|
|
991
|
+
$match: {
|
|
992
|
+
userEmail: { $in: req.body.userFilter },
|
|
993
|
+
},
|
|
994
|
+
} );
|
|
995
|
+
}
|
|
890
996
|
let ticketList = await aggregateTangoTicket( query );
|
|
891
997
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
892
998
|
const categoryCounts = {};
|
|
@@ -933,7 +1039,6 @@ export async function installationTable( req, res ) {
|
|
|
933
1039
|
} );
|
|
934
1040
|
}
|
|
935
1041
|
let count = await aggregateTangoTicket( query );
|
|
936
|
-
console.log( count.length );
|
|
937
1042
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
938
1043
|
query.push(
|
|
939
1044
|
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
@@ -977,3 +1082,19 @@ export async function assignTicket( req, res ) {
|
|
|
977
1082
|
return res.sendError( error, 500 );
|
|
978
1083
|
}
|
|
979
1084
|
}
|
|
1085
|
+
export async function storeFilter( req, res ) {
|
|
1086
|
+
try {
|
|
1087
|
+
let stores = await findTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': { $exists: true } }, { 'basicDetails.storeId': 1 } );
|
|
1088
|
+
const uniqueStoreIds = [ ...new Set( stores.map( ( store ) => store.basicDetails.storeId ) ) ];
|
|
1089
|
+
const uniqueStoreObjects = uniqueStoreIds.map( ( storeId ) => ( { 'storeId': storeId } ) );
|
|
1090
|
+
|
|
1091
|
+
if ( uniqueStoreObjects.length>0 ) {
|
|
1092
|
+
res.sendSuccess( { count: uniqueStoreObjects.length, data: uniqueStoreObjects } );
|
|
1093
|
+
} else {
|
|
1094
|
+
res.sendError( 'No data' );
|
|
1095
|
+
}
|
|
1096
|
+
} catch ( error ) {
|
|
1097
|
+
logger.error( { error: error, function: 'storeFilter' } );
|
|
1098
|
+
return res.sendError( error, 500 );
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
|
4
4
|
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
5
5
|
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons,
|
|
6
6
|
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments,
|
|
7
|
-
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
7
|
+
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export const infraRouter = express.Router();
|
|
@@ -67,3 +67,7 @@ infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
|
|
|
67
67
|
userType: [ 'client', 'tango' ], access: [
|
|
68
68
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|
|
69
69
|
} ), assignTicket );
|
|
70
|
+
infraRouter.post( '/storeFilter', isAllowedSessionHandler, authorize( {
|
|
71
|
+
userType: [ 'tango' ], access: [
|
|
72
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
73
|
+
} ), storeFilter );
|
|
@@ -325,7 +325,6 @@ export async function InfraAlert( req, res, next ) {
|
|
|
325
325
|
await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
|
|
326
326
|
|
|
327
327
|
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
|
|
328
|
-
console.log( req.body.ticketActivity );
|
|
329
328
|
} else {
|
|
330
329
|
if ( req.body.issueType == 'infra' ) {
|
|
331
330
|
let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
|