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