tango-app-api-infra 3.1.33 → 3.1.34-beta.0

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
  "name": "tango-app-api-infra",
3
- "version": "3.1.33",
3
+ "version": "3.1.34-beta.0",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,7 +29,7 @@ export async function createTicket( req, res ) {
29
29
  actionBy: 'Tango',
30
30
  IdentifiedBy: 'Tango',
31
31
  } ];
32
- let ticketExists= await findOneTangoTicket( { ticketId: req.body.ticketId } );
32
+ let ticketExists = await findOneTangoTicket( { ticketId: req.body.ticketId } );
33
33
  if ( ticketExists ) {
34
34
  return res.status( 200 ).send( { message: 'ticketId Exists', storeId: req.body.storeId } );
35
35
  }
@@ -243,7 +243,8 @@ export async function updateTicketIssue( req, res ) {
243
243
  let client = await findOneClient( { clientId: req.body.basicDetails.clientId } );
244
244
  let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
245
245
 
246
- query = { ...query, 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
246
+ query = {
247
+ ...query, 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
247
248
  };
248
249
  }
249
250
 
@@ -661,7 +662,7 @@ export async function invoice( req, res ) {
661
662
  export async function getInfraIssues( req, res ) {
662
663
  try {
663
664
  const inputData = req.body;
664
- const query=[
665
+ const query = [
665
666
  {
666
667
  $match: {
667
668
  $and: [
@@ -761,7 +762,7 @@ export async function getInfraIssues( req, res ) {
761
762
 
762
763
  const result = await aggregateTangoTicket( query );
763
764
 
764
- const mergeValue =_.values(
765
+ const mergeValue = _.values(
765
766
  _.merge(
766
767
  _.keyBy( retVal, 'issueDate' ),
767
768
  _.keyBy( result, 'issueDate' ),
@@ -771,7 +772,7 @@ export async function getInfraIssues( req, res ) {
771
772
  if ( mergeValue.length == 0 ) {
772
773
  return res.sendError( 'NO Data Found', 204 );
773
774
  }
774
- for ( let i =0; i< mergeValue.length; i++ ) {
775
+ for ( let i = 0; i < mergeValue.length; i++ ) {
775
776
  const downTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly,
776
777
  {
777
778
  'size': 100,
@@ -836,7 +837,7 @@ export async function getInfraIssues( req, res ) {
836
837
 
837
838
  if ( downTime.body.hits.hits.length > 0 ) {
838
839
  let down = 0;
839
- for ( let j = 0; j< downTime.body.hits.hits.length; j++ ) {
840
+ for ( let j = 0; j < downTime.body.hits.hits.length; j++ ) {
840
841
  const sum = streamwiseDowntime[j]?._source?.doc?.streamwise_downtime?.reduce( ( accumulator, currentValue ) => {
841
842
  return accumulator + currentValue.down_time;
842
843
  }, 0 );
@@ -851,8 +852,8 @@ export async function getInfraIssues( req, res ) {
851
852
  }
852
853
 
853
854
  if ( speedTest.body.hits.hits.length > 0 ) {
854
- const uploadspeed =Number( speedTest.body.hits.hits[0]?._source?.data?.upload_Speed.split( ' ' )[0] );
855
- const converToMb = ( uploadspeed/ 1048576 ).toFixed( 1 );
855
+ const uploadspeed = Number( speedTest.body.hits.hits[0]?._source?.data?.upload_Speed.split( ' ' )[0] );
856
+ const converToMb = ( uploadspeed / 1048576 ).toFixed( 1 );
856
857
  mergeValue[i].speedTest = Number( converToMb );
857
858
  }
858
859
  }
@@ -876,7 +877,7 @@ export async function getInfraIssues( req, res ) {
876
877
  },
877
878
  ];
878
879
 
879
- const highCountQuery =[
880
+ const highCountQuery = [
880
881
  {
881
882
  $match: {
882
883
  $and: [
@@ -897,11 +898,11 @@ export async function getInfraIssues( req, res ) {
897
898
  $project: {
898
899
  _id: 0,
899
900
  total: 1,
900
- successRate: 1,
901
+ successRate: { $round: [ '$successRate', 2 ] },
901
902
  },
902
903
  },
903
904
  ];
904
- const defaultValue= {
905
+ const defaultValue = {
905
906
  total: 0,
906
907
  successRate: 0,
907
908
  };
@@ -943,7 +944,7 @@ function inWords( num ) {
943
944
  export async function allCounts( req, res ) {
944
945
  try {
945
946
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
946
- let countQuery=[];
947
+ let countQuery = [];
947
948
 
948
949
  if ( req.body.permittedStores && req.body.permittedStores.length > 0 ) {
949
950
  countQuery.push(
@@ -1241,10 +1242,10 @@ export async function infraTable( req, res ) {
1241
1242
  'count': ticketList.length,
1242
1243
  } );
1243
1244
  let notIdentifiedCount = ticketList.reduce( ( count, ticket ) => {
1244
- return ticket.ticketStatus === 'notidentified'&&ticket.status!='closed' ? count + 1 : count;
1245
+ return ticket.ticketStatus === 'notidentified' && ticket.status != 'closed' ? count + 1 : count;
1245
1246
  }, 0 );
1246
1247
  let AutoClosedCount = ticketList.reduce( ( count, ticket ) => {
1247
- return ticket.ticketStatus === 'notidentified'&&ticket.status=='closed' ? count + 1 : count;
1248
+ return ticket.ticketStatus === 'notidentified' && ticket.status == 'closed' ? count + 1 : count;
1248
1249
  }, 0 );
1249
1250
  response.unshift( {
1250
1251
  'name': 'Yet to Address',
@@ -1254,7 +1255,7 @@ export async function infraTable( req, res ) {
1254
1255
  'name': 'Auto Closed',
1255
1256
  'count': AutoClosedCount,
1256
1257
  } );
1257
- if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total'&&req.body.filterIssue != 'Yet to Address'&&req.body.filterIssue != 'Auto Closed' ) {
1258
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' && req.body.filterIssue != 'Yet to Address' && req.body.filterIssue != 'Auto Closed' ) {
1258
1259
  query.push( {
1259
1260
  $match: {
1260
1261
  primaryIssue: req.body.filterIssue,
@@ -1298,7 +1299,7 @@ export async function infraTable( req, res ) {
1298
1299
  let result = await aggregateTangoTicket( query );
1299
1300
  if ( req.body.export && result.length > 0 ) {
1300
1301
  const exportdata = [];
1301
- if ( req.user.userType ==='tango' ) {
1302
+ if ( req.user.userType === 'tango' ) {
1302
1303
  result.forEach( ( element ) => {
1303
1304
  exportdata.push( {
1304
1305
  'Ticket ID': element.ticketId,
@@ -1311,7 +1312,7 @@ export async function infraTable( req, res ) {
1311
1312
  'Status': element.status,
1312
1313
  'Primary Issues': element.primaryIssue,
1313
1314
  'Secondary Issues': element.secondaryIssue,
1314
- 'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
1315
+ 'Comment': element.otherscomment ? element.otherscomment : ( element.commentText ? element.commentText : '-' ),
1315
1316
  } );
1316
1317
  } );
1317
1318
  } else {
@@ -1324,7 +1325,7 @@ export async function infraTable( req, res ) {
1324
1325
  'Status': element.status,
1325
1326
  'Primary Issues': element.primaryIssue,
1326
1327
  'Secondary Issues': element.secondaryIssue,
1327
- 'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
1328
+ 'Comment': element.otherscomment ? element.otherscomment : ( element.commentText ? element.commentText : '-' ),
1328
1329
  } );
1329
1330
  } );
1330
1331
  }
@@ -1513,7 +1514,7 @@ export async function installationTable( req, res ) {
1513
1514
  let response;
1514
1515
  if ( ticketList.length > 0 ) {
1515
1516
  ticketList.forEach( ( item ) => {
1516
- if ( item.installationStatus!='deployed' ) {
1517
+ if ( item.installationStatus != 'deployed' ) {
1517
1518
  const categoryName = item.primaryIssue;
1518
1519
  if ( categoryCounts[categoryName] ) {
1519
1520
  categoryCounts[categoryName]++;
@@ -1537,7 +1538,7 @@ export async function installationTable( req, res ) {
1537
1538
  'count': ticketList.length,
1538
1539
  } );
1539
1540
  let notIdentifiedCount = ticketList.reduce( ( count, ticket ) => {
1540
- return ticket.ticketStatus === 'notidentified'&&( ticket.installationStatus=='onboarded'||ticket.installationStatus=='paired' ) ? count + 1 : count;
1541
+ return ticket.ticketStatus === 'notidentified' && ( ticket.installationStatus == 'onboarded' || ticket.installationStatus == 'paired' ) ? count + 1 : count;
1541
1542
  }, 0 );
1542
1543
  let AutoClosedCount = ticketList.reduce( ( count, ticket ) => {
1543
1544
  return ticket.installationStatus === 'deployed' ? count + 1 : count;
@@ -1550,7 +1551,7 @@ export async function installationTable( req, res ) {
1550
1551
  'name': 'Deployed',
1551
1552
  'count': AutoClosedCount,
1552
1553
  } );
1553
- if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total'&&req.body.filterIssue != 'Yet to Address'&&req.body.filterIssue != 'Deployed' ) {
1554
+ if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'total' && req.body.filterIssue != 'Yet to Address' && req.body.filterIssue != 'Deployed' ) {
1554
1555
  query.push( {
1555
1556
  $match: {
1556
1557
  primaryIssue: req.body.filterIssue,
@@ -1604,7 +1605,7 @@ export async function installationTable( req, res ) {
1604
1605
 
1605
1606
  if ( req.body.export && result.length > 0 ) {
1606
1607
  const exportdata = [];
1607
- if ( req.user.userType ==='tango' ) {
1608
+ if ( req.user.userType === 'tango' ) {
1608
1609
  result.forEach( ( element ) => {
1609
1610
  exportdata.push( {
1610
1611
  'Ticket ID': element.ticketId,
@@ -1615,7 +1616,7 @@ export async function installationTable( req, res ) {
1615
1616
  'Store ID': element.storeId,
1616
1617
  'Installed By': element.userName,
1617
1618
  'Deployed Status': element.installationStatus,
1618
- 'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
1619
+ 'Primary Issues': element.primaryIssue == '-' ? 'Issue not identified' : element.primaryIssue,
1619
1620
  'Secondary Issues': element.secondaryIssue,
1620
1621
  } );
1621
1622
  } );
@@ -1627,7 +1628,7 @@ export async function installationTable( req, res ) {
1627
1628
  'Store Name': element.storeName,
1628
1629
  'Store ID': element.storeId,
1629
1630
  'Deployed Status': element.installationStatus,
1630
- 'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
1631
+ 'Primary Issues': element.primaryIssue == '-' ? 'Issue not identified' : element.primaryIssue,
1631
1632
  'Secondary Issues': element.secondaryIssue,
1632
1633
  } );
1633
1634
  } );
@@ -1825,7 +1826,7 @@ export async function storeFilter( req, res ) {
1825
1826
  const inputData = req.body;
1826
1827
  let query = { 'issueType': inputData.issueType, 'basicDetails.clientId': inputData.clientId, 'basicDetails.storeId': { $exists: true } };
1827
1828
  if ( inputData.issueType == 'dataMismatch' ) {
1828
- query ={
1829
+ query = {
1829
1830
  'issueType': { '$in': [ 'highcount', 'lowcount' ] }, 'basicDetails.clientId': inputData.clientId, 'basicDetails.storeId': { $exists: true },
1830
1831
  };
1831
1832
  }
@@ -2041,20 +2042,31 @@ export async function dataMismatchTable( req, res ) {
2041
2042
 
2042
2043
  if ( inputData?.filterIssue && inputData?.filterIssue != '' ) {
2043
2044
  const issueType = inputData.filterIssue == 'total' ? [ 'highcount', 'lowcount' ] : [ inputData.filterIssue ];
2044
- filter.push( {
2045
- issueType: { $in: issueType },
2045
+ query.push( {
2046
+ $match: {
2047
+ issueType: { $in: issueType },
2048
+ },
2046
2049
  } );
2047
2050
  }
2048
2051
 
2052
+
2049
2053
  if ( inputData?.filterByStores && inputData?.filterByStores?.length > 0 ) {
2050
- filter.push( {
2051
- 'storeId': { $in: inputData.filterByStores },
2054
+ query.push( {
2055
+
2056
+ $match: {
2057
+ 'storeId': { $in: inputData.filterByStores },
2058
+
2059
+ },
2060
+
2052
2061
  } );
2053
2062
  }
2054
2063
 
2055
2064
  if ( inputData?.filterByStatus && inputData?.filterByStatus?.length > 0 ) {
2056
- filter.push( {
2057
- status: { $in: inputData.filterByStatus },
2065
+ query.push( {
2066
+
2067
+ $match: {
2068
+ status: { $in: inputData.filterByStatus },
2069
+ },
2058
2070
  } );
2059
2071
  }
2060
2072
 
@@ -2067,15 +2079,17 @@ export async function dataMismatchTable( req, res ) {
2067
2079
  }
2068
2080
 
2069
2081
  if ( inputData.searchValue && inputData.searchValue !== '' ) {
2070
- filter.push( {
2071
- $or: [
2072
- { 'clientName': { $regex: req.body.searchValue, $options: 'i' } },
2073
- { 'storeId': { $regex: req.body.searchValue, $options: 'i' } },
2074
- { 'storeName': { $regex: req.body.searchValue, $options: 'i' } },
2075
- { 'status': { $regex: req.body.searchValue, $options: 'i' } },
2076
- { 'ticketId': { $regex: req.body.searchValue, $options: 'i' } },
2077
- { 'issueType': { $regex: req.body.searchValue, $options: 'i' } },
2078
- ],
2082
+ query.push( {
2083
+ $match: {
2084
+ $or: [
2085
+ { 'clientName': { $regex: req.body.searchValue, $options: 'i' } },
2086
+ { 'storeId': { $regex: req.body.searchValue, $options: 'i' } },
2087
+ { 'storeName': { $regex: req.body.searchValue, $options: 'i' } },
2088
+ { 'status': { $regex: req.body.searchValue, $options: 'i' } },
2089
+ { 'ticketId': { $regex: req.body.searchValue, $options: 'i' } },
2090
+ { 'issueType': { $regex: req.body.searchValue, $options: 'i' } },
2091
+ ],
2092
+ },
2079
2093
  } );
2080
2094
  }
2081
2095
 
@@ -2089,13 +2103,13 @@ export async function dataMismatchTable( req, res ) {
2089
2103
  }
2090
2104
 
2091
2105
  const count = await aggregateTangoTicket( query );
2106
+
2092
2107
  query.push(
2093
2108
  { $skip: offset },
2094
2109
  { $limit: limit },
2095
2110
  );
2096
2111
  const result = await aggregateTangoTicket( query );
2097
2112
 
2098
-
2099
2113
  if ( inputData.export ) {
2100
2114
  const resultChunk = await chunkArray( count, 10 );
2101
2115
  const promises = resultChunk.map( async ( chunk ) => {
@@ -2144,7 +2158,7 @@ export async function dataMismatchTable( req, res ) {
2144
2158
 
2145
2159
  export async function checkPermission( req, res, next ) {
2146
2160
  try {
2147
- let result =[];
2161
+ let result = [];
2148
2162
  if ( req.user.role !== 'superadmin' && req.user.userType == 'client' ) {
2149
2163
  const assignedUser = await findUserAssignedStore( { userEmail: req.user.email } );
2150
2164
  if ( assignedUser.length == 0 ) {
@@ -2236,9 +2250,9 @@ export async function checkPermission( req, res, next ) {
2236
2250
  result = await aggregateUserAssignedStore( assignedQuery );
2237
2251
  break;
2238
2252
  }
2239
- if ( result&&result.length>0 ) {
2253
+ if ( result && result.length > 0 ) {
2240
2254
  const uniqueArray = [ ...new Set( result[0].storeList ) ];
2241
- req.body.permittedStores =uniqueArray;
2255
+ req.body.permittedStores = uniqueArray;
2242
2256
  }
2243
2257
  }
2244
2258
  next();
@@ -1053,7 +1053,6 @@ export async function updateIssue( data ) {
1053
1053
  timeStamp: statusCheckAlertTime,
1054
1054
  actionBy: 'Tango',
1055
1055
  IdentifiedBy: 'Tango',
1056
- timeStamp: new Date(),
1057
1056
  statusCheckAlertTime: statusCheckAlertTime,
1058
1057
  } );
1059
1058
  }
@@ -42,7 +42,6 @@ export async function userTakeTicket( req, res ) {
42
42
  'ticketDetails.ticketType': 'refreshticket',
43
43
  'ticketDetails.refreshTicketStatus': 'notidentified',
44
44
  };
45
- console.log( query, assignedClients );
46
45
 
47
46
  if ( assignedClients.length > 0 ) {
48
47
  query = ( { ...query, ...{ 'basicDetails.clientId': { $in: assignedClients } } } );
@@ -8,38 +8,38 @@ export const clientInfraRouter = express.Router();
8
8
 
9
9
  clientInfraRouter.post( '/infraCard', isAllowedSessionHandler, authorize( {
10
10
  userType: [ 'client', 'tango' ], access: [
11
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
11
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
12
12
  } ), checkPermission, infraCard );
13
13
  clientInfraRouter.post( '/infraIssuesTable', isAllowedSessionHandler, authorize( {
14
14
  userType: [ 'client', 'tango' ], access: [
15
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
15
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
16
16
  } ), checkPermission, infraIssuesTable );
17
17
  clientInfraRouter.post( '/installationCard', isAllowedSessionHandler, authorize( {
18
18
  userType: [ 'client', 'tango' ], access: [
19
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
19
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
20
20
  } ), checkPermission, installationCard );
21
21
  clientInfraRouter.post( '/InstallationIssuesTable', isAllowedSessionHandler, authorize( {
22
22
  userType: [ 'client', 'tango' ], access: [
23
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
23
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
24
24
  } ), checkPermission, InstallationIssuesTable );
25
25
  clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, authorize( {
26
26
  userType: [ 'client', 'tango' ], access: [
27
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
27
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
28
28
  } ), hourWiseDownClients );
29
29
  clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, authorize( {
30
30
  userType: [ 'client', 'tango' ], access: [
31
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
31
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
32
32
  } ), checkPermission, hourWiseDownstores );
33
33
 
34
34
  clientInfraRouter.post( '/ticket-count', isAllowedSessionHandler, authorize( {
35
35
  userType: [ 'client', 'tango' ], access: [
36
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
36
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
37
37
  } ), checkPermission, ticketCount );
38
38
  clientInfraRouter.post( '/ticket-count-split', isAllowedSessionHandler, authorize( {
39
39
  userType: [ 'client', 'tango' ], access: [
40
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
40
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
41
41
  } ), checkPermission, ticketCountSplit );
42
42
  clientInfraRouter.post( '/overview-table', isAllowedSessionHandler, authorize( {
43
43
  userType: [ 'client', 'tango' ], access: [
44
- { featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
44
+ { featureName: 'manage', name: 'overview', permissions: [ 'isView' ] } ],
45
45
  } ), checkPermission, overViewTable );
@@ -366,7 +366,6 @@ export async function InfraAlert( req, res, next ) {
366
366
  timeStamp: statusCheckAlertTime,
367
367
  actionBy: 'Tango',
368
368
  IdentifiedBy: 'Tango',
369
- timeStamp: new Date(),
370
369
  statusCheckAlertTime: statusCheckAlertTime,
371
370
  } );
372
371
  }