tango-app-api-infra 3.1.13 → 3.1.15
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/clientInfra.controller.js +110 -29
- package/src/controllers/employeeTraning.controller.js +1 -1
- package/src/controllers/infra.controllers.js +214 -25
- package/src/controllers/internalInfra.controller.js +19 -13
- package/src/controllers/storeInfra.controlller.js +285 -55
- package/src/controllers/userInfra.controller.js +26 -24
- package/src/routes/infra.routes.js +5 -1
- package/src/routes/storeInfra.routes.js +9 -1
- package/src/services/tangoTicket.service.js +3 -0
|
@@ -3,9 +3,9 @@
|
|
|
3
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
|
-
import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
|
|
6
|
+
import { logger, fileUpload, signedUrl, sendEmailWithSES, getOpenSearchData, insertOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
|
|
7
7
|
import { aggregateUser, updateOneUser } from '../services/user.service.js';
|
|
8
|
-
import { updateoneClient } from '../services/client.service.js';
|
|
8
|
+
import { findOneClient, updateoneClient } from '../services/client.service.js';
|
|
9
9
|
import dayjs from 'dayjs';
|
|
10
10
|
import { readFileSync } from 'fs';
|
|
11
11
|
import { join } from 'path';
|
|
@@ -26,6 +26,10 @@ export async function createTicket( req, res ) {
|
|
|
26
26
|
actionBy: 'Tango',
|
|
27
27
|
IdentifiedBy: 'Tango',
|
|
28
28
|
} ];
|
|
29
|
+
let ticketExists= await findOneTangoTicket( { ticketId: req.body.ticketId } );
|
|
30
|
+
if ( ticketExists ) {
|
|
31
|
+
res.status( 200 ).send( { storeId: req.body.storeId } );
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
if ( req.body.issueType == 'installation' ) {
|
|
31
35
|
req.body.ticketId = 'TE_INS_' + new Date().valueOf();
|
|
@@ -332,6 +336,17 @@ export async function AlertTicketReply( req, res ) {
|
|
|
332
336
|
return res.sendError( error, 500 );
|
|
333
337
|
}
|
|
334
338
|
}
|
|
339
|
+
export async function removeAttachment( req, res ) {
|
|
340
|
+
try {
|
|
341
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.params.ticketId }, { attachments: req.body.attachments } );
|
|
342
|
+
if ( updateTicket ) {
|
|
343
|
+
res.sendSuccess( 'Removed successfully' );
|
|
344
|
+
}
|
|
345
|
+
} catch ( error ) {
|
|
346
|
+
logger.error( { error: error, function: 'uploadAttachments' } );
|
|
347
|
+
return res.sendError( error, 500 );
|
|
348
|
+
}
|
|
349
|
+
}
|
|
335
350
|
export async function uploadAttachments( req, res ) {
|
|
336
351
|
try {
|
|
337
352
|
if ( req.files.img && req.files.img.length > 0 ) {
|
|
@@ -503,7 +518,7 @@ export async function emailUserList( req, res ) {
|
|
|
503
518
|
export async function saveInfraEmailConfig( req, res ) {
|
|
504
519
|
try {
|
|
505
520
|
let inputData = req.body;
|
|
506
|
-
|
|
521
|
+
let client = await findOneClient( { clientId: inputData.clientId } );
|
|
507
522
|
await updateoneClient( { clientId: inputData.clientId }, {
|
|
508
523
|
'ticketConfigs.infraReport': {
|
|
509
524
|
start: inputData.start,
|
|
@@ -520,6 +535,29 @@ export async function saveInfraEmailConfig( req, res ) {
|
|
|
520
535
|
} );
|
|
521
536
|
}
|
|
522
537
|
}
|
|
538
|
+
|
|
539
|
+
const logObj = {
|
|
540
|
+
clientId: inputData.clientId,
|
|
541
|
+
userName: req.user?.userName,
|
|
542
|
+
email: req.user?.email,
|
|
543
|
+
date: new Date(),
|
|
544
|
+
logType: 'configuration',
|
|
545
|
+
logSubType: 'emailConfig',
|
|
546
|
+
eventType: 'update',
|
|
547
|
+
showTo: [ 'tango' ],
|
|
548
|
+
changes: [ `Email Config` ],
|
|
549
|
+
previous: client.ticketConfigs.infraReport,
|
|
550
|
+
current: {
|
|
551
|
+
infraReport: {
|
|
552
|
+
start: inputData.start,
|
|
553
|
+
end: inputData.end,
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
559
|
+
|
|
560
|
+
|
|
523
561
|
res.sendSuccess( 'Updated Successfully' );
|
|
524
562
|
} catch ( error ) {
|
|
525
563
|
logger.error( { error: error, function: 'emailUserList' } );
|
|
@@ -692,7 +730,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
692
730
|
primaryIssue: 1,
|
|
693
731
|
secondaryReason: 1,
|
|
694
732
|
downTime: { $ifNull: [ 0, 0 ] },
|
|
695
|
-
speedTest:
|
|
733
|
+
speedTest: null,
|
|
696
734
|
},
|
|
697
735
|
|
|
698
736
|
},
|
|
@@ -704,7 +742,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
704
742
|
let end = new Date( inputData.toDate );
|
|
705
743
|
|
|
706
744
|
while ( current <= end ) {
|
|
707
|
-
retVal.push( { issueDate: dayjs( current ).format( 'YYYY-MM-DD' ), downTime: 0, speedTest:
|
|
745
|
+
retVal.push( { issueDate: dayjs( current ).format( 'YYYY-MM-DD' ), downTime: 0, speedTest: null } );
|
|
708
746
|
current.setDate( current.getDate() + 1 );
|
|
709
747
|
}
|
|
710
748
|
|
|
@@ -716,7 +754,6 @@ export async function getInfraIssues( req, res ) {
|
|
|
716
754
|
_.keyBy( result, 'issueDate' ),
|
|
717
755
|
),
|
|
718
756
|
);
|
|
719
|
-
logger.info( { message: mergeValue, value1: result } );
|
|
720
757
|
|
|
721
758
|
if ( mergeValue.length == 0 ) {
|
|
722
759
|
return res.sendError( 'NO Data Found', 204 );
|
|
@@ -745,17 +782,65 @@ export async function getInfraIssues( req, res ) {
|
|
|
745
782
|
},
|
|
746
783
|
|
|
747
784
|
} );
|
|
748
|
-
|
|
749
|
-
|
|
785
|
+
|
|
786
|
+
const speedTest = await getOpenSearchData( 'edgeapp_systemlogs',
|
|
787
|
+
{
|
|
788
|
+
'size': 1,
|
|
789
|
+
'query': {
|
|
790
|
+
'bool': {
|
|
791
|
+
'must': [
|
|
792
|
+
{
|
|
793
|
+
'term': {
|
|
794
|
+
'store_date.keyword': dayjs( mergeValue[i].issueDate ).format( 'DD-MM-YYYY' ),
|
|
795
|
+
},
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
'term': {
|
|
799
|
+
'storeId.keyword': inputData.storeId,
|
|
800
|
+
},
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
'term': {
|
|
804
|
+
'log_subtype.keyword': 'Speed_Test',
|
|
805
|
+
},
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
],
|
|
809
|
+
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
|
|
813
|
+
'sort': [
|
|
814
|
+
{
|
|
815
|
+
'timestamp': {
|
|
816
|
+
'order': 'desc',
|
|
817
|
+
},
|
|
818
|
+
},
|
|
819
|
+
],
|
|
820
|
+
|
|
821
|
+
} );
|
|
822
|
+
let streamwiseDowntime = downTime.body.hits.hits;
|
|
823
|
+
|
|
750
824
|
if ( downTime.body.hits.hits.length > 0 ) {
|
|
751
|
-
|
|
752
|
-
|
|
825
|
+
let down = 0;
|
|
826
|
+
for ( let j = 0; j< downTime.body.hits.hits.length; j++ ) {
|
|
827
|
+
const sum = streamwiseDowntime[j]?._source?.doc?.streamwise_downtime?.reduce( ( accumulator, currentValue ) => {
|
|
753
828
|
return accumulator + currentValue.down_time;
|
|
754
829
|
}, 0 );
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
830
|
+
if ( streamwiseDowntime[j]?._source?.doc?.streamwise_downtime?.length > 0 ) {
|
|
831
|
+
const average = sum / streamwiseDowntime[j]?._source?.doc?.streamwise_downtime?.length;
|
|
832
|
+
|
|
833
|
+
down = down + Math.round( average );
|
|
834
|
+
logger.info( { down: down, downTine: mergeValue[i].downTime, streamwiseData: streamwiseDowntime[j]?._source?.doc?.streamwise_downtime } );
|
|
835
|
+
}
|
|
758
836
|
}
|
|
837
|
+
mergeValue[i].downTime = down;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
if ( speedTest.body.hits.hits.length > 0 ) {
|
|
841
|
+
const uploadspeed =Number( speedTest.body.hits.hits[0]?._source?.data?.upload_Speed.split( ' ' )[0] );
|
|
842
|
+
const converToMb = ( uploadspeed/ 1048576 ).toFixed( 1 );
|
|
843
|
+
mergeValue[i].speedTest = Number( converToMb );
|
|
759
844
|
}
|
|
760
845
|
}
|
|
761
846
|
const camQuery = [
|
|
@@ -773,7 +858,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
773
858
|
_id: 0,
|
|
774
859
|
streamName: 1,
|
|
775
860
|
cameraNumber: 1,
|
|
776
|
-
thumbnailImage:
|
|
861
|
+
thumbnailImage: '$thumbnailImage',
|
|
777
862
|
},
|
|
778
863
|
},
|
|
779
864
|
];
|
|
@@ -808,8 +893,12 @@ export async function getInfraIssues( req, res ) {
|
|
|
808
893
|
successRate: 0,
|
|
809
894
|
};
|
|
810
895
|
const getHighCountTicket = await aggregateTangoTicket( highCountQuery );
|
|
811
|
-
logger.info( { getHighCountTicket: getHighCountTicket } );
|
|
812
896
|
const camera = await aggregateCamera( camQuery );
|
|
897
|
+
for ( let index = 0; index < camera.length; index++ ) {
|
|
898
|
+
if ( camera?.[index]?.thumbnailImage ) {
|
|
899
|
+
camera[index].thumbnailImage = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.baseImage, file_path: camera[index].thumbnailImage } );
|
|
900
|
+
}
|
|
901
|
+
}
|
|
813
902
|
logger.info( { message: camera } );
|
|
814
903
|
return res.sendSuccess( { result: mergeValue, streams: camera, highCountTicketDetails: getHighCountTicket[0] || defaultValue } );
|
|
815
904
|
} catch ( error ) {
|
|
@@ -861,6 +950,7 @@ export async function infraTable( req, res ) {
|
|
|
861
950
|
ticketId: 1,
|
|
862
951
|
storeName: '$basicDetails.storeName',
|
|
863
952
|
clientName: '$basicDetails.clientName',
|
|
953
|
+
ticketStatus: '$ticketDetails.issueStatus',
|
|
864
954
|
status: 1,
|
|
865
955
|
createdAt: 1,
|
|
866
956
|
issueDate: 1,
|
|
@@ -872,6 +962,20 @@ export async function infraTable( req, res ) {
|
|
|
872
962
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
873
963
|
},
|
|
874
964
|
},
|
|
965
|
+
otherscomment: {
|
|
966
|
+
$filter: {
|
|
967
|
+
input: '$ticketActivity',
|
|
968
|
+
as: 'item',
|
|
969
|
+
cond: { $eq: [ '$$item.actionType', 'comment' ] },
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
comments: {
|
|
973
|
+
$filter: {
|
|
974
|
+
input: '$ticketActivity',
|
|
975
|
+
as: 'item',
|
|
976
|
+
cond: { $ne: [ '$$item.actionType', 'statusChange' ] },
|
|
977
|
+
},
|
|
978
|
+
},
|
|
875
979
|
},
|
|
876
980
|
},
|
|
877
981
|
{
|
|
@@ -884,6 +988,11 @@ export async function infraTable( req, res ) {
|
|
|
884
988
|
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
885
989
|
},
|
|
886
990
|
},
|
|
991
|
+
{
|
|
992
|
+
$unwind: {
|
|
993
|
+
path: '$otherscomment', preserveNullAndEmptyArrays: true,
|
|
994
|
+
},
|
|
995
|
+
},
|
|
887
996
|
{
|
|
888
997
|
$unwind: {
|
|
889
998
|
path: '$primaryIssue.reasons.secondaryIssue', preserveNullAndEmptyArrays: true,
|
|
@@ -897,9 +1006,12 @@ export async function infraTable( req, res ) {
|
|
|
897
1006
|
clientName: 1,
|
|
898
1007
|
createdAt: 1,
|
|
899
1008
|
addressingUser: 1,
|
|
1009
|
+
ticketStatus: 1,
|
|
900
1010
|
ticketId: 1,
|
|
901
1011
|
issueDate: { $ifNull: [ '$issueDate', '' ] },
|
|
902
1012
|
status: 1,
|
|
1013
|
+
commentText: '$primaryIssue.comment',
|
|
1014
|
+
otherscomment: '$otherscomment.comment',
|
|
903
1015
|
primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
|
|
904
1016
|
secondaryIssue: { $ifNull: [ '$primaryIssue.reasons.secondaryIssue.name', '-' ] },
|
|
905
1017
|
},
|
|
@@ -941,12 +1053,15 @@ export async function infraTable( req, res ) {
|
|
|
941
1053
|
clientId: { $first: '$clientId' },
|
|
942
1054
|
ticketId: { $first: '$ticketId' },
|
|
943
1055
|
storeName: { $first: '$storeName' },
|
|
1056
|
+
ticketStatus: { $first: '$ticketStatus' },
|
|
944
1057
|
userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
|
|
945
1058
|
userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
|
|
946
1059
|
clientName: { $first: '$clientName' },
|
|
947
1060
|
createdAt: { $first: '$createdAt' },
|
|
948
1061
|
issueDate: { $last: '$issueDate' },
|
|
949
1062
|
status: { $last: '$status' },
|
|
1063
|
+
commentText: { $last: '$commentText' },
|
|
1064
|
+
otherscomment: { $last: '$otherscomment' },
|
|
950
1065
|
primaryIssue: { $last: '$primaryIssue' },
|
|
951
1066
|
secondaryIssue: { $last: '$secondaryIssue' },
|
|
952
1067
|
},
|
|
@@ -1006,19 +1121,48 @@ export async function infraTable( req, res ) {
|
|
|
1006
1121
|
count: 0,
|
|
1007
1122
|
} ) );
|
|
1008
1123
|
}
|
|
1124
|
+
|
|
1009
1125
|
response.push( {
|
|
1010
1126
|
'name': 'total',
|
|
1011
1127
|
'count': ticketList.length,
|
|
1012
|
-
|
|
1013
1128
|
} );
|
|
1014
|
-
|
|
1129
|
+
let notIdentifiedCount = ticketList.reduce( ( count, ticket ) => {
|
|
1130
|
+
return ticket.ticketStatus === 'notidentified'&&ticket.status!='closed' ? count + 1 : count;
|
|
1131
|
+
}, 0 );
|
|
1132
|
+
let AutoClosedCount = ticketList.reduce( ( count, ticket ) => {
|
|
1133
|
+
return ticket.ticketStatus === 'notidentified'&&ticket.status=='closed' ? count + 1 : count;
|
|
1134
|
+
}, 0 );
|
|
1135
|
+
response.unshift( {
|
|
1136
|
+
'name': 'Yet to Address',
|
|
1137
|
+
'count': notIdentifiedCount,
|
|
1138
|
+
} );
|
|
1139
|
+
response.unshift( {
|
|
1140
|
+
'name': 'Auto Closed',
|
|
1141
|
+
'count': AutoClosedCount,
|
|
1142
|
+
} );
|
|
1143
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total'&&req.body.filterIssue != 'Yet to Address'&&req.body.filterIssue != 'Auto Closed' ) {
|
|
1015
1144
|
query.push( {
|
|
1016
1145
|
$match: {
|
|
1017
1146
|
primaryIssue: req.body.filterIssue,
|
|
1018
1147
|
},
|
|
1019
1148
|
} );
|
|
1020
1149
|
}
|
|
1021
|
-
|
|
1150
|
+
if ( req.body.filterIssue == 'Yet to Address' ) {
|
|
1151
|
+
query.push( {
|
|
1152
|
+
$match: {
|
|
1153
|
+
ticketStatus: 'notidentified',
|
|
1154
|
+
status: { $ne: 'closed' },
|
|
1155
|
+
},
|
|
1156
|
+
} );
|
|
1157
|
+
}
|
|
1158
|
+
if ( req.body.filterIssue == 'Auto Closed' ) {
|
|
1159
|
+
query.push( {
|
|
1160
|
+
$match: {
|
|
1161
|
+
ticketStatus: 'notidentified',
|
|
1162
|
+
status: 'closed',
|
|
1163
|
+
},
|
|
1164
|
+
} );
|
|
1165
|
+
}
|
|
1022
1166
|
if ( req.body.searchValue && req.body.searchValue != '' ) {
|
|
1023
1167
|
query.push( {
|
|
1024
1168
|
$match: {
|
|
@@ -1053,6 +1197,7 @@ export async function infraTable( req, res ) {
|
|
|
1053
1197
|
'Status': element.status,
|
|
1054
1198
|
'StatusDetails': element.primaryIssue,
|
|
1055
1199
|
'SubIssue': element.secondaryIssue,
|
|
1200
|
+
'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
|
|
1056
1201
|
} );
|
|
1057
1202
|
} );
|
|
1058
1203
|
await download( exportdata, res );
|
|
@@ -1096,6 +1241,7 @@ export async function installationTable( req, res ) {
|
|
|
1096
1241
|
ticketId: 1,
|
|
1097
1242
|
storeName: '$basicDetails.storeName',
|
|
1098
1243
|
clientName: '$basicDetails.clientName',
|
|
1244
|
+
ticketStatus: '$ticketDetails.issueStatus',
|
|
1099
1245
|
status: 1,
|
|
1100
1246
|
createdAt: 1,
|
|
1101
1247
|
addressingUser: '$ticketDetails.addressingUser',
|
|
@@ -1133,6 +1279,7 @@ export async function installationTable( req, res ) {
|
|
|
1133
1279
|
clientName: 1,
|
|
1134
1280
|
createdAt: 1,
|
|
1135
1281
|
ticketId: 1,
|
|
1282
|
+
ticketStatus: 1,
|
|
1136
1283
|
addressingUser: 1,
|
|
1137
1284
|
installationStatus: { $ifNull: [ '$installationStatus', '-' ] },
|
|
1138
1285
|
issueDate: { $ifNull: [ '$issueDate', '' ] },
|
|
@@ -1178,6 +1325,7 @@ export async function installationTable( req, res ) {
|
|
|
1178
1325
|
clientId: { $first: '$clientId' },
|
|
1179
1326
|
ticketId: { $first: '$ticketId' },
|
|
1180
1327
|
storeName: { $first: '$storeName' },
|
|
1328
|
+
ticketStatus: { $first: '$ticketStatus' },
|
|
1181
1329
|
userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
|
|
1182
1330
|
userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
|
|
1183
1331
|
clientName: { $first: '$clientName' },
|
|
@@ -1227,11 +1375,13 @@ export async function installationTable( req, res ) {
|
|
|
1227
1375
|
let response;
|
|
1228
1376
|
if ( ticketList.length > 0 ) {
|
|
1229
1377
|
ticketList.forEach( ( item ) => {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
categoryCounts[categoryName]
|
|
1233
|
-
|
|
1234
|
-
|
|
1378
|
+
if ( item.installationStatus!='deployed' ) {
|
|
1379
|
+
const categoryName = item.primaryIssue;
|
|
1380
|
+
if ( categoryCounts[categoryName] ) {
|
|
1381
|
+
categoryCounts[categoryName]++;
|
|
1382
|
+
} else {
|
|
1383
|
+
categoryCounts[categoryName] = 1;
|
|
1384
|
+
}
|
|
1235
1385
|
}
|
|
1236
1386
|
} );
|
|
1237
1387
|
response = issueList.map( ( category ) => ( {
|
|
@@ -1247,15 +1397,54 @@ export async function installationTable( req, res ) {
|
|
|
1247
1397
|
response.push( {
|
|
1248
1398
|
'name': 'total',
|
|
1249
1399
|
'count': ticketList.length,
|
|
1250
|
-
|
|
1251
1400
|
} );
|
|
1252
|
-
|
|
1401
|
+
let notIdentifiedCount = ticketList.reduce( ( count, ticket ) => {
|
|
1402
|
+
return ticket.ticketStatus === 'notidentified'&&( ticket.installationStatus=='onboarded'||ticket.installationStatus=='paired' ) ? count + 1 : count;
|
|
1403
|
+
}, 0 );
|
|
1404
|
+
let AutoClosedCount = ticketList.reduce( ( count, ticket ) => {
|
|
1405
|
+
return ticket.installationStatus === 'deployed' ? count + 1 : count;
|
|
1406
|
+
}, 0 );
|
|
1407
|
+
response.unshift( {
|
|
1408
|
+
'name': 'Yet to Address',
|
|
1409
|
+
'count': notIdentifiedCount,
|
|
1410
|
+
} );
|
|
1411
|
+
response.unshift( {
|
|
1412
|
+
'name': 'Deployed',
|
|
1413
|
+
'count': AutoClosedCount,
|
|
1414
|
+
} );
|
|
1415
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total'&&req.body.filterIssue != 'Yet to Address'&&req.body.filterIssue != 'Deployed' ) {
|
|
1253
1416
|
query.push( {
|
|
1254
1417
|
$match: {
|
|
1255
1418
|
primaryIssue: req.body.filterIssue,
|
|
1256
1419
|
},
|
|
1257
1420
|
} );
|
|
1258
1421
|
}
|
|
1422
|
+
if ( req.body.filterIssue == 'Yet to Address' ) {
|
|
1423
|
+
query.push( {
|
|
1424
|
+
$match: {
|
|
1425
|
+
$and: [
|
|
1426
|
+
{
|
|
1427
|
+
$or: [
|
|
1428
|
+
{ installationStatus: 'onboarded' },
|
|
1429
|
+
{ installationStatus: 'paired' },
|
|
1430
|
+
],
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
ticketStatus: 'notidentified',
|
|
1434
|
+
},
|
|
1435
|
+
],
|
|
1436
|
+
|
|
1437
|
+
|
|
1438
|
+
},
|
|
1439
|
+
} );
|
|
1440
|
+
}
|
|
1441
|
+
if ( req.body.filterIssue == 'Deployed' ) {
|
|
1442
|
+
query.push( {
|
|
1443
|
+
$match: {
|
|
1444
|
+
installationStatus: 'deployed',
|
|
1445
|
+
},
|
|
1446
|
+
} );
|
|
1447
|
+
}
|
|
1259
1448
|
if ( req.body.searchValue && req.body.searchValue != '' ) {
|
|
1260
1449
|
query.push( {
|
|
1261
1450
|
$match: {
|
|
@@ -12,7 +12,7 @@ dayjs.extend( timezone );
|
|
|
12
12
|
import { sendEmailWithSES, signedUrl } from 'tango-app-api-middleware';
|
|
13
13
|
import { createClient, findClient, aggregateClient, findOneClient } from '../services/client.service.js';
|
|
14
14
|
import { createStore, findStore, updateOneStore, findOneStore } from '../services/store.service.js';
|
|
15
|
-
import { findTangoTicket, findOneTangoTicket, countDocumentsTangoTicket, aggregateTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
15
|
+
import { findTangoTicket, findOneTangoTicket, countDocumentsTangoTicket, updateOneTangoTicketunset, aggregateTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
16
16
|
import { findOneGroup } from '../services/group.service.js';
|
|
17
17
|
import { findinfraReason } from '../services/infraReason.service.js';
|
|
18
18
|
import { findOneUser } from '../services/user.service.js';
|
|
@@ -74,9 +74,9 @@ export async function migrateStores() {
|
|
|
74
74
|
}
|
|
75
75
|
export async function clientList( req, res ) {
|
|
76
76
|
try {
|
|
77
|
-
let
|
|
77
|
+
let clientList = await findClient( { status: { $in: [ 'active', 'hold' ] } },
|
|
78
78
|
{ 'clientName': 1, 'clientId': 1, 'ticketConfigs': 1 } );
|
|
79
|
-
res.sendSuccess(
|
|
79
|
+
res.sendSuccess( clientList );
|
|
80
80
|
} catch ( error ) {
|
|
81
81
|
logger.error( { error: error, function: 'basicList' } );
|
|
82
82
|
res.sendError( error, 500 );
|
|
@@ -85,7 +85,12 @@ export async function clientList( req, res ) {
|
|
|
85
85
|
|
|
86
86
|
export async function basicList( req, res ) {
|
|
87
87
|
try {
|
|
88
|
-
let
|
|
88
|
+
let clientList = await findClient( { status: { $in: [ 'active', 'hold' ] } }, { 'clientId': 1 } );
|
|
89
|
+
let clients = [];
|
|
90
|
+
for ( let client of clientList ) {
|
|
91
|
+
clients.push( client.clientId );
|
|
92
|
+
}
|
|
93
|
+
let storeList = await findStore( { 'clientId': { $in: clients }, 'status': 'active', 'edge.firstFile': true },
|
|
89
94
|
{ 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
|
|
90
95
|
res.sendSuccess( storeList );
|
|
91
96
|
} catch ( error ) {
|
|
@@ -152,6 +157,7 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
152
157
|
for ( let ticket of req.body.TicketList ) {
|
|
153
158
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
154
159
|
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
|
|
160
|
+
await updateOneTangoTicketunset( { ticketId: ticket.ticketId }, { 'ticketDetails.addressingUser': 1 } );
|
|
155
161
|
let downTimeQuery = {
|
|
156
162
|
'size': 1,
|
|
157
163
|
'query': {
|
|
@@ -448,12 +454,12 @@ export async function infraReportSent( req, res ) {
|
|
|
448
454
|
// if ( req.body.type == 'start' ) {
|
|
449
455
|
// date = dayjs().subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
|
|
450
456
|
// } else if ( req.body.type == 'end' ) {
|
|
451
|
-
let date = dayjs(
|
|
457
|
+
let date = dayjs().format( 'YYYY-MM-DD' );
|
|
452
458
|
// };
|
|
453
459
|
let query = [ {
|
|
454
460
|
$match: {
|
|
455
461
|
$and: [
|
|
456
|
-
{ issueDate: new Date( date ) },
|
|
462
|
+
{ issueDate: { $lte: new Date( date ) } },
|
|
457
463
|
{ 'basicDetails.storeId': { $in: req.body.storeList } },
|
|
458
464
|
{ issueType: 'infra' },
|
|
459
465
|
],
|
|
@@ -550,10 +556,10 @@ export async function infraReportSent( req, res ) {
|
|
|
550
556
|
'Responded By': clientuser && clientuser.userName ? clientuser.userName : '-',
|
|
551
557
|
'Resolved By': tangouser && tangouser.userName ? tangouser.userName : '-',
|
|
552
558
|
'Ticket Closed Date & Time': element.issueClosedDate ? dayjs( element.issueClosedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ) : '-',
|
|
553
|
-
'Latest Comment': element.otherscomment?element.otherscomment:element.commentText,
|
|
559
|
+
'Latest Comment': element.otherscomment ? element.otherscomment : element.commentText,
|
|
554
560
|
'Activity Log': {
|
|
555
561
|
label: 'Link',
|
|
556
|
-
url: `${appConfig.url.domain+'/manage/stores/infra-ticket?storeId='+element.basicDetails.storeId}`,
|
|
562
|
+
url: `${appConfig.url.domain + '/manage/stores/infra-ticket?storeId=' + element.basicDetails.storeId}`,
|
|
557
563
|
},
|
|
558
564
|
} );
|
|
559
565
|
}
|
|
@@ -724,7 +730,7 @@ export async function download( data ) {
|
|
|
724
730
|
for ( let j = 0; j < headers.length; j++ ) {
|
|
725
731
|
const header = headers[j];
|
|
726
732
|
const value = dataRow[header];
|
|
727
|
-
if ( value&& typeof value === 'object' && value.hasOwnProperty( 'label' ) && value.hasOwnProperty( 'url' ) ) {
|
|
733
|
+
if ( value && typeof value === 'object' && value.hasOwnProperty( 'label' ) && value.hasOwnProperty( 'url' ) ) {
|
|
728
734
|
ws.cell( i + 2, j + 1 ).link( value.url );
|
|
729
735
|
ws.cell( i + 2, j + 1 ).string( value.label );
|
|
730
736
|
} else {
|
|
@@ -736,7 +742,7 @@ export async function download( data ) {
|
|
|
736
742
|
}
|
|
737
743
|
export async function edgeApplogsCheck( req, res ) {
|
|
738
744
|
try {
|
|
739
|
-
let finalresult= [];
|
|
745
|
+
let finalresult = [];
|
|
740
746
|
let ticketList = await findTangoTicket( { 'issueDate': new Date( req.body.issueDate ), 'status': { $ne: 'closed' }, 'ticketDetails.issueStatus': 'notidentified', 'issueType': 'infra' } );
|
|
741
747
|
for ( let ticket of ticketList ) {
|
|
742
748
|
req.body.date = dayjs( ticket.createdAt ).format( 'YYYY-MM-DD' );
|
|
@@ -881,7 +887,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
881
887
|
}
|
|
882
888
|
}
|
|
883
889
|
let findissueEdgeApp = {};
|
|
884
|
-
if ( result.length>0 ) {
|
|
890
|
+
if ( result.length > 0 ) {
|
|
885
891
|
for ( let findissue of result ) {
|
|
886
892
|
const istTimestamp = dayjs.utc( ticket.createdAt ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' );
|
|
887
893
|
|
|
@@ -908,7 +914,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
908
914
|
const existsInArray = finalresult.some( ( item ) =>
|
|
909
915
|
item.ticketId === ticket.ticketId,
|
|
910
916
|
);
|
|
911
|
-
if ( isOccurringTimeEarlier
|
|
917
|
+
if ( isOccurringTimeEarlier && !existsInArray ) {
|
|
912
918
|
findissueEdgeApp = {
|
|
913
919
|
ticketId: ticket.ticketId,
|
|
914
920
|
storeId: ticket.basicDetails.storeId,
|
|
@@ -935,7 +941,7 @@ export async function edgeApplogsCheck( req, res ) {
|
|
|
935
941
|
updateIssue( findissueEdgeApp );
|
|
936
942
|
finalresult.push( findissueEdgeApp );
|
|
937
943
|
}
|
|
938
|
-
} else if ( findissue.code ==='1005' ) {
|
|
944
|
+
} else if ( findissue.code === '1005' ) {
|
|
939
945
|
const occurringTimeParsed = dayjs( `${req.body.date} ${findissue.edgelog.occuringTime}` );
|
|
940
946
|
const ticketCreatedParsed = dayjs( `${req.body.date} ${istTimestamp}` );
|
|
941
947
|
const isOccurringTimeEarlier = occurringTimeParsed.isBefore( ticketCreatedParsed );
|