tango-app-api-infra 3.0.98-dev → 3.0.99-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
  "name": "tango-app-api-infra",
3
- "version": "3.0.98-dev",
3
+ "version": "3.0.99-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -10,7 +10,21 @@ import { getOpenSearchData } from 'tango-app-api-middleware';
10
10
  export async function infraCard( req, res ) {
11
11
  try {
12
12
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
13
- let storeCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'edge.firstFile': true, 'status': 'active' } );
13
+ let storeCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'status': 'active' } );
14
+ let yettoInstallCount = await aggregateTangoTicket( [
15
+ {
16
+ $match: {
17
+ $and: [
18
+ { issueType: 'installation' },
19
+ { 'status': { $ne: 'closed' } },
20
+ { 'ticketDetails.issueStatus': 'notidentified' },
21
+ { 'basicDetails.clientId': { $in: req.body.clientId } },
22
+ { createdAt: { $lte: date.end } },
23
+ ],
24
+ },
25
+ },
26
+ ] );
27
+ storeCount = storeCount-yettoInstallCount.length;
14
28
  let totalstores = await aggregateStore( [ {
15
29
  $match: {
16
30
  '$and': [
@@ -3,7 +3,7 @@
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, insertOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
6
+ import { logger, fileUpload, signedUrl, chunkArray, sendEmailWithSES, getOpenSearchData, insertOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
7
7
  import { aggregateUser, updateOneUser } from '../services/user.service.js';
8
8
  import { findOneClient, updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
@@ -1238,17 +1238,16 @@ export async function infraTable( req, res ) {
1238
1238
  const exportdata = [];
1239
1239
  result.forEach( ( element ) => {
1240
1240
  exportdata.push( {
1241
- 'ticketId': element.ticketId,
1242
- 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1243
- 'storeId': element.storeId,
1244
- 'storeName': element.storeName,
1245
- 'clientId': element.clientId,
1246
- 'clientName': element.clientName,
1247
- 'userName': element.userName,
1248
- 'userEmail': element.userEmail,
1241
+ 'Ticket ID': element.ticketId,
1242
+ 'Created Date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
1243
+ 'Brand Name': element.clientName,
1244
+ 'Brand ID': element.clientId,
1245
+ 'Store Name': element.storeName,
1246
+ 'Store ID': element.storeId,
1247
+ 'Resloved By': element.userName,
1249
1248
  'Status': element.status,
1250
- 'StatusDetails': element.primaryIssue,
1251
- 'SubIssue': element.secondaryIssue,
1249
+ 'Primary Issues': element.primaryIssue,
1250
+ 'Secondary Issues': element.secondaryIssue,
1252
1251
  'Comment': element.otherscomment ? element.otherscomment : ( element.commentText?element.commentText:'-' ),
1253
1252
  } );
1254
1253
  } );
@@ -1520,17 +1519,16 @@ export async function installationTable( req, res ) {
1520
1519
  const exportdata = [];
1521
1520
  result.forEach( ( element ) => {
1522
1521
  exportdata.push( {
1523
- 'ticketId': element.ticketId,
1524
- 'issueDate': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1525
- 'storeId': element.storeId,
1526
- 'storeName': element.storeName,
1527
- 'clientId': element.clientId,
1528
- 'clientName': element.clientName,
1529
- 'userName': element.userName,
1530
- 'userEmail': element.userEmail,
1531
- 'Status': element.installationStatus,
1532
- 'StatusDetails': element.primaryIssue,
1533
- 'SubIssue': element.secondaryIssue,
1522
+ 'Ticket ID': element.ticketId,
1523
+ 'Created Date': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
1524
+ 'Brand Name': element.clientName,
1525
+ 'Brand ID': element.clientId,
1526
+ 'Store Name': element.storeName,
1527
+ 'Store ID': element.storeId,
1528
+ 'Installed By': element.userName,
1529
+ 'Deployed Status': element.installationStatus,
1530
+ 'Primary Issues': element.primaryIssue=='-'?'Issue not identified':element.primaryIssue,
1531
+ 'Secondary Issues': element.secondaryIssue,
1534
1532
  } );
1535
1533
  } );
1536
1534
  await download( exportdata, res );
@@ -1684,14 +1682,13 @@ export async function matTable( req, res ) {
1684
1682
  const exportdata = [];
1685
1683
  result.forEach( ( element ) => {
1686
1684
  exportdata.push( {
1687
- 'ticketId': element.ticketId,
1688
- 'Date': dayjs( element.issueDate ).format( 'DD-MM-YYYY' ),
1689
- 'storeId': element.storeId,
1690
- 'storeName': element.storeName,
1691
- 'clientId': element.clientId,
1692
- 'clientName': element.clientName,
1693
- 'userName': element.userName,
1694
- 'userEmail': element.userEmail,
1685
+ 'Ticket ID': element.ticketId,
1686
+ 'Created Date': dayjs( element.createdAt ).format( 'DD MMM, YYYY' ),
1687
+ 'Brand Name': element.clientName,
1688
+ 'Brand ID': element.clientId,
1689
+ 'Store Name': element.storeName,
1690
+ 'Store ID': element.storeId,
1691
+ 'Resloved By': element.userName,
1695
1692
  'Status': element.status,
1696
1693
  } );
1697
1694
  } );
@@ -1749,6 +1746,7 @@ export async function storeFilter( req, res ) {
1749
1746
  export async function dataMismatchTable( req, res ) {
1750
1747
  try {
1751
1748
  const inputData = req.body;
1749
+ let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
1752
1750
  const defaultValue = [
1753
1751
  { name: 'Low Count', count: 0 },
1754
1752
  { name: 'High Count', count: 0 },
@@ -1757,8 +1755,8 @@ export async function dataMismatchTable( req, res ) {
1757
1755
  ];
1758
1756
 
1759
1757
  let countFilter = [
1760
- { issueDate: { $gte: new Date( inputData.fromDate ) } },
1761
- { issueDate: { $lte: new Date( inputData.toDate ) } },
1758
+ { createdAt: { $gte: date.start } },
1759
+ { createdAt: { $lte: date.end } },
1762
1760
  {
1763
1761
  issueType: { $in: [ 'highcount', 'lowcount' ] },
1764
1762
  },
@@ -1820,8 +1818,8 @@ export async function dataMismatchTable( req, res ) {
1820
1818
  const limit = inputData.limit || 10;
1821
1819
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
1822
1820
  let filter = [
1823
- { issueDate: { $gte: new Date( inputData.fromDate ) } },
1824
- { issueDate: { $lte: new Date( inputData.toDate ) } },
1821
+ { createdAt: { $gte: date.start } },
1822
+ { createdAt: { $lte: date.end } },
1825
1823
  { 'basicDetails.clientId': { $in: inputData.clientId } },
1826
1824
  { issueType: { $in: [ 'highcount', 'lowcount' ] } },
1827
1825
  ];
@@ -1833,8 +1831,8 @@ export async function dataMismatchTable( req, res ) {
1833
1831
  },
1834
1832
  {
1835
1833
  $project: {
1836
- createdAt: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
1837
- issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
1834
+ createdAt: 1,
1835
+ issueDate: 1,
1838
1836
  ticketId: 1,
1839
1837
  clientName: '$basicDetails.clientName',
1840
1838
  clientId: '$basicDetails.clientId',
@@ -1843,9 +1841,16 @@ export async function dataMismatchTable( req, res ) {
1843
1841
  userId: { $ifNull: [ '$ticketDetails.addressingUser', '$$REMOVE' ] },
1844
1842
  issueType: 1,
1845
1843
  status: 1,
1846
-
1844
+ otherscomment: {
1845
+ $filter: {
1846
+ input: '$ticketActivity',
1847
+ as: 'item',
1848
+ cond: { $eq: [ '$$item.actionType', 'comment' ] },
1849
+ },
1850
+ },
1847
1851
  },
1848
1852
  },
1853
+
1849
1854
  {
1850
1855
  $lookup: {
1851
1856
  from: 'users',
@@ -1875,6 +1880,27 @@ export async function dataMismatchTable( req, res ) {
1875
1880
  preserveNullAndEmptyArrays: true,
1876
1881
  },
1877
1882
  },
1883
+ {
1884
+ $unwind: {
1885
+ path: '$otherscomment', preserveNullAndEmptyArrays: true,
1886
+ },
1887
+ },
1888
+ {
1889
+ $group: {
1890
+ _id: '$ticketId',
1891
+ createdAt: { $first: '$createdAt' },
1892
+ issueDate: { $first: '$issueDate' },
1893
+ ticketId: { $first: '$ticketId' },
1894
+ clientName: { $first: '$clientName' },
1895
+ clientId: { $first: '$clientId' },
1896
+ storeName: { $first: '$storeName' },
1897
+ storeId: { $first: '$storeId' },
1898
+ userInfo: { $first: '$userInfo' },
1899
+ issueType: { $first: '$issueType' },
1900
+ status: { $first: '$status' },
1901
+ otherscomment: { $last: '$otherscomment.comment' },
1902
+ },
1903
+ },
1878
1904
  {
1879
1905
  $project: {
1880
1906
  createdAt: 1,
@@ -1889,6 +1915,7 @@ export async function dataMismatchTable( req, res ) {
1889
1915
  type: { $ifNull: [ { $cond: [ { $eq: [ '$userInfo.userType', 'client' ] }, 'external', { $cond: [ { $eq: [ '$userInfo.userType', 'tango' ] }, 'internal', '' ] } ] }, '' ] },
1890
1916
  issueType: 1,
1891
1917
  status: 1,
1918
+ otherscomment: 1,
1892
1919
  },
1893
1920
  },
1894
1921
 
@@ -1903,7 +1930,7 @@ export async function dataMismatchTable( req, res ) {
1903
1930
 
1904
1931
  if ( inputData?.filterByStores && inputData?.filterByStores?.length > 0 ) {
1905
1932
  filter.push( {
1906
- 'basicDetails.storeId': { $in: inputData.filterByStores },
1933
+ 'storeId': { $in: inputData.filterByStores },
1907
1934
  } );
1908
1935
  }
1909
1936
 
@@ -1923,33 +1950,27 @@ export async function dataMismatchTable( req, res ) {
1923
1950
 
1924
1951
  if ( inputData.searchValue && inputData.searchValue !== '' ) {
1925
1952
  filter.push( {
1926
-
1927
1953
  $or: [
1928
- { 'basicDetails.clientName': { $regex: req.body.searchValue, $options: 'i' } },
1929
- { 'basicDetails.storeId': { $regex: req.body.searchValue, $options: 'i' } },
1930
- { 'basicDetails.storeName': { $regex: req.body.searchValue, $options: 'i' } },
1954
+ { 'clientName': { $regex: req.body.searchValue, $options: 'i' } },
1955
+ { 'storeId': { $regex: req.body.searchValue, $options: 'i' } },
1956
+ { 'storeName': { $regex: req.body.searchValue, $options: 'i' } },
1931
1957
  { 'status': { $regex: req.body.searchValue, $options: 'i' } },
1932
1958
  { 'ticketId': { $regex: req.body.searchValue, $options: 'i' } },
1933
1959
  { 'issueType': { $regex: req.body.searchValue, $options: 'i' } },
1934
1960
  ],
1935
-
1936
1961
  } );
1937
1962
  }
1938
1963
 
1939
- if ( inputData.sortColumName ) {
1964
+ if ( inputData.sortColumnName ) {
1940
1965
  const sortBy = inputData.sortBy || -1;
1941
1966
  query.push( {
1942
1967
  $sort: {
1943
- [inputData.sortColumName == 'storeId' ? 'basicDetails.storeId' :
1944
- inputData.sortColumName == 'clientName' ? 'basicDetails.clientName' :
1945
- inputData.sortColumName == 'storeName' ? 'basicDetails.storeName' : inputData.sortColumName]: sortBy,
1968
+ [inputData.sortColumnName]: sortBy,
1946
1969
  },
1947
1970
  } );
1948
1971
  }
1949
1972
 
1950
1973
  const count = await aggregateTangoTicket( query );
1951
-
1952
-
1953
1974
  query.push(
1954
1975
  { $skip: offset },
1955
1976
  { $limit: limit },
@@ -1963,31 +1984,29 @@ export async function dataMismatchTable( req, res ) {
1963
1984
  const list = [];
1964
1985
  for ( let i = 0; i < chunk.length; i++ ) {
1965
1986
  req.user.userType == 'tango' ?
1966
-
1967
1987
  list.push( {
1968
- 'Created Date': chunk[i]?.createdAt,
1969
- 'Issue Date': chunk[i]?.issueDate,
1970
1988
  'Ticket ID': chunk[i]?.ticketId,
1971
- 'Brand ID': chunk[i]?.clientId,
1989
+ 'Created Date': dayjs( chunk[i]?.createdAt ).format( 'DD MMM, YYYY' ),
1990
+ 'Issue Date': dayjs( chunk[i]?.issueDate ).format( 'DD MMM, YYYY' ),
1972
1991
  'Brand Name': chunk[i]?.clientName,
1973
- 'Store ID': chunk[i]?.storeId,
1992
+ 'Brand ID': chunk[i]?.clientId,
1974
1993
  'Store Name': chunk[i]?.storeName,
1975
- 'User Name': chunk[i]?.userName,
1976
- 'User Email': chunk[i]?.email,
1994
+ 'Store ID': chunk[i]?.storeId,
1995
+ 'Resloved By': chunk[i]?.userName,
1977
1996
  'Issue Type': chunk[i]?.issueType,
1978
- 'Type': chunk[i]?.type,
1997
+ 'Query Type ': chunk[i]?.type,
1979
1998
  'Status': chunk[i]?.status,
1980
-
1999
+ 'Comment': chunk[i]?.otherscomment,
1981
2000
  } ) :
1982
2001
  list.push( {
2002
+ 'Ticket ID': chunk[i]?.ticketId,
1983
2003
  'Created Date': chunk[i]?.createdAt,
1984
2004
  'Issue Date': chunk[i]?.issueDate,
1985
- 'Ticket ID': chunk[i]?.clientName,
1986
- 'Store ID': chunk[i]?.storeId,
1987
2005
  'Store Name': chunk[i]?.storeName,
2006
+ 'Store ID': chunk[i]?.storeId,
1988
2007
  'Issue Type': chunk[i]?.issueType,
1989
- 'Type': chunk[i]?.type,
1990
2008
  'Status': chunk[i]?.status,
2009
+ 'Comment': chunk[i]?.otherscomment,
1991
2010
  } );
1992
2011
  }
1993
2012
  return list;
@@ -1001,6 +1001,8 @@ export async function streamwiseDowntime( req, res ) {
1001
1001
  for ( let stream of streamwiseDowntime ) {
1002
1002
  if ( stream.stream === req.body.stream ) {
1003
1003
  obj.downTime= stream.down_time;
1004
+ } else {
1005
+ obj.downTime= '';
1004
1006
  }
1005
1007
  }
1006
1008
  } else {