tango-app-api-infra 3.0.92-dev → 3.0.94-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 +1 -1
- package/src/controllers/clientInfra.controller.js +609 -72
- package/src/controllers/dataMismatch.controller.js +28 -13
- package/src/controllers/infra.controllers.js +310 -0
- package/src/controllers/storeInfra.controlller.js +11 -9
- package/src/controllers/userInfra.controller.js +55 -0
- package/src/routes/clientInfra.routes.js +13 -2
- package/src/routes/infra.routes.js +9 -1
- package/src/routes/userInfra.routes.js +6 -2
|
@@ -8,7 +8,7 @@ export async function createTicket( req, res ) {
|
|
|
8
8
|
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
|
|
9
9
|
|
|
10
10
|
if ( ticketExist ) {
|
|
11
|
-
return res.sendSuccess( '
|
|
11
|
+
return res.sendSuccess( 'Ticket Already Exists for the store' );
|
|
12
12
|
}
|
|
13
13
|
let actionBy = '';
|
|
14
14
|
if ( req.user.userType == 'tango' ) {
|
|
@@ -21,6 +21,7 @@ export async function createTicket( req, res ) {
|
|
|
21
21
|
actualCount: req.body.actualCount,
|
|
22
22
|
expectedCount: req.body.expectedCount,
|
|
23
23
|
contactEmail: req.body.contactEmail,
|
|
24
|
+
showToClient: req.body.showToClient,
|
|
24
25
|
};
|
|
25
26
|
req.body.issueDate = new Date( req.body.Date );
|
|
26
27
|
req.body.ticketId = 'TE_DM_' + new Date().valueOf();
|
|
@@ -106,17 +107,31 @@ export async function updateMat( req, res ) {
|
|
|
106
107
|
export async function activityList( req, res ) {
|
|
107
108
|
try {
|
|
108
109
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
109
|
-
let query = [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
110
|
+
let query = [ ];
|
|
111
|
+
if ( req.body.fromDate == req.body.toDate ) {
|
|
112
|
+
query.push( {
|
|
113
|
+
$match: {
|
|
114
|
+
$and: [
|
|
115
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
116
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
117
|
+
{ createdAt: { $lte: date.end } },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
} );
|
|
121
|
+
} else {
|
|
122
|
+
query.push( {
|
|
123
|
+
$match: {
|
|
124
|
+
$and: [
|
|
125
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
126
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
127
|
+
{ createdAt: { $gte: date.start } },
|
|
128
|
+
{ createdAt: { $lte: date.end } },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
} );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
query.push( {
|
|
120
135
|
$project: {
|
|
121
136
|
storeId: '$basicDetails.storeId',
|
|
122
137
|
status: 1,
|
|
@@ -153,7 +168,7 @@ export async function activityList( req, res ) {
|
|
|
153
168
|
issueDate: -1,
|
|
154
169
|
},
|
|
155
170
|
},
|
|
156
|
-
|
|
171
|
+
);
|
|
157
172
|
|
|
158
173
|
if ( req.body.filter && req.body.filter !== '' ) {
|
|
159
174
|
query.push( {
|
|
@@ -921,8 +921,60 @@ function inWords( num ) {
|
|
|
921
921
|
|
|
922
922
|
return str.toLowerCase().split( ' ' ).map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) ).join( ' ' );
|
|
923
923
|
}
|
|
924
|
+
export async function allCounts( req, res ) {
|
|
925
|
+
try {
|
|
926
|
+
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
927
|
+
let countQuery=[
|
|
928
|
+
{
|
|
929
|
+
$match: {
|
|
930
|
+
$and: [
|
|
931
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
932
|
+
{ createdAt: { $gte: date.start } },
|
|
933
|
+
{ createdAt: { $lte: date.end } },
|
|
934
|
+
],
|
|
935
|
+
},
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
$project: {
|
|
939
|
+
issueType: 1,
|
|
940
|
+
installationCount: {
|
|
941
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'installation' ] } ] }, 1, 0,
|
|
942
|
+
],
|
|
943
|
+
},
|
|
944
|
+
infraCount: {
|
|
945
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'infra' ] } ] }, 1, 0,
|
|
946
|
+
],
|
|
947
|
+
},
|
|
948
|
+
datamismatchCount: {
|
|
949
|
+
$cond: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, 1, 0,
|
|
950
|
+
],
|
|
951
|
+
},
|
|
952
|
+
matCount: {
|
|
953
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] } ] }, 1, 0,
|
|
954
|
+
],
|
|
955
|
+
},
|
|
956
|
+
},
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
$group: {
|
|
960
|
+
_id: null,
|
|
961
|
+
installationCount: { $sum: '$installationCount' },
|
|
962
|
+
infraCount: { $sum: '$infraCount' },
|
|
963
|
+
datamismatchCount: { $sum: '$datamismatchCount' },
|
|
964
|
+
matCount: { $sum: '$matCount' },
|
|
924
965
|
|
|
925
966
|
|
|
967
|
+
},
|
|
968
|
+
},
|
|
969
|
+
];
|
|
970
|
+
let result = await aggregateTangoTicket( countQuery );
|
|
971
|
+
res.sendSuccess( result );
|
|
972
|
+
} catch ( error ) {
|
|
973
|
+
logger.error( { error: error, function: 'allCounts' } );
|
|
974
|
+
return res.sendError( error, 500 );
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
926
978
|
export async function infraTable( req, res ) {
|
|
927
979
|
try {
|
|
928
980
|
let query = [];
|
|
@@ -1694,3 +1746,261 @@ export async function storeFilter( req, res ) {
|
|
|
1694
1746
|
}
|
|
1695
1747
|
}
|
|
1696
1748
|
|
|
1749
|
+
export async function dataMismatchTable( req, res ) {
|
|
1750
|
+
try {
|
|
1751
|
+
const inputData = req.body;
|
|
1752
|
+
const defaultValue = [
|
|
1753
|
+
{ name: 'Low Count', count: 0 },
|
|
1754
|
+
{ name: 'High Count', count: 0 },
|
|
1755
|
+
{ name: 'Total', count: 0 },
|
|
1756
|
+
|
|
1757
|
+
];
|
|
1758
|
+
|
|
1759
|
+
let countFilter = [
|
|
1760
|
+
{ issueDate: { $gte: new Date( inputData.fromDate ) } },
|
|
1761
|
+
{ issueDate: { $lte: new Date( inputData.toDate ) } },
|
|
1762
|
+
{
|
|
1763
|
+
issueType: { $in: [ 'highcount', 'lowcount' ] },
|
|
1764
|
+
},
|
|
1765
|
+
|
|
1766
|
+
];
|
|
1767
|
+
if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
|
|
1768
|
+
countFilter.push( {
|
|
1769
|
+
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1770
|
+
} );
|
|
1771
|
+
}
|
|
1772
|
+
const countQuery = [
|
|
1773
|
+
{
|
|
1774
|
+
$match: {
|
|
1775
|
+
$and: countFilter,
|
|
1776
|
+
},
|
|
1777
|
+
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
$project: {
|
|
1781
|
+
high: {
|
|
1782
|
+
$cond: [
|
|
1783
|
+
{
|
|
1784
|
+
$eq: [ '$issueType', 'highcount' ],
|
|
1785
|
+
}, 1, 0,
|
|
1786
|
+
],
|
|
1787
|
+
},
|
|
1788
|
+
low: {
|
|
1789
|
+
$cond: [
|
|
1790
|
+
{ $eq: [ '$issueType', 'lowcount' ] }, 1, 0,
|
|
1791
|
+
],
|
|
1792
|
+
},
|
|
1793
|
+
},
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
$group: {
|
|
1797
|
+
_id: null,
|
|
1798
|
+
highCount: { $sum: '$high' },
|
|
1799
|
+
LowCount: { $sum: '$low' },
|
|
1800
|
+
total: { $sum: 1 },
|
|
1801
|
+
|
|
1802
|
+
},
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
$project: {
|
|
1806
|
+
_id: 0,
|
|
1807
|
+
response: [
|
|
1808
|
+
{ name: 'Low Count', count: '$LowCount' },
|
|
1809
|
+
{ name: 'High Count', count: '$highCount' },
|
|
1810
|
+
{ name: 'Total', count: '$total' },
|
|
1811
|
+
],
|
|
1812
|
+
},
|
|
1813
|
+
},
|
|
1814
|
+
|
|
1815
|
+
];
|
|
1816
|
+
|
|
1817
|
+
const response = await aggregateTangoTicket( countQuery );
|
|
1818
|
+
|
|
1819
|
+
|
|
1820
|
+
const limit = inputData.limit || 10;
|
|
1821
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1822
|
+
let filter = [
|
|
1823
|
+
{ issueDate: { $gte: new Date( inputData.fromDate ) } },
|
|
1824
|
+
{ issueDate: { $lte: new Date( inputData.toDate ) } },
|
|
1825
|
+
{ 'basicDetails.clientId': { $in: inputData.clientId } },
|
|
1826
|
+
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1827
|
+
];
|
|
1828
|
+
const query = [
|
|
1829
|
+
{
|
|
1830
|
+
$match: {
|
|
1831
|
+
$and: filter,
|
|
1832
|
+
},
|
|
1833
|
+
},
|
|
1834
|
+
{
|
|
1835
|
+
$project: {
|
|
1836
|
+
createdAt: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
1837
|
+
issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
1838
|
+
ticketId: 1,
|
|
1839
|
+
clientName: '$basicDetails.clientName',
|
|
1840
|
+
clientId: '$basicDetails.clientId',
|
|
1841
|
+
storeName: '$basicDetails.storeName',
|
|
1842
|
+
storeId: '$basicDetails.storeId',
|
|
1843
|
+
userId: { $ifNull: [ '$ticketDetails.addressingUser', '$$REMOVE' ] },
|
|
1844
|
+
issueType: 1,
|
|
1845
|
+
status: 1,
|
|
1846
|
+
|
|
1847
|
+
},
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
$lookup: {
|
|
1851
|
+
from: 'users',
|
|
1852
|
+
let: { userId: '$userId' },
|
|
1853
|
+
pipeline: [
|
|
1854
|
+
{
|
|
1855
|
+
$match: {
|
|
1856
|
+
$expr: {
|
|
1857
|
+
$eq: [ '$_id', '$$userId' ],
|
|
1858
|
+
},
|
|
1859
|
+
},
|
|
1860
|
+
},
|
|
1861
|
+
{
|
|
1862
|
+
$project: {
|
|
1863
|
+
userName: 1,
|
|
1864
|
+
userType: 1,
|
|
1865
|
+
email: 1,
|
|
1866
|
+
},
|
|
1867
|
+
},
|
|
1868
|
+
], as: 'userInfo',
|
|
1869
|
+
},
|
|
1870
|
+
},
|
|
1871
|
+
|
|
1872
|
+
{
|
|
1873
|
+
$unwind: {
|
|
1874
|
+
path: '$userInfo',
|
|
1875
|
+
preserveNullAndEmptyArrays: true,
|
|
1876
|
+
},
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
$project: {
|
|
1880
|
+
createdAt: 1,
|
|
1881
|
+
issueDate: 1,
|
|
1882
|
+
ticketId: 1,
|
|
1883
|
+
clientName: 1,
|
|
1884
|
+
clientId: 1,
|
|
1885
|
+
storeName: 1,
|
|
1886
|
+
storeId: 1,
|
|
1887
|
+
userName: { $ifNull: [ '$userInfo.userName', '' ] },
|
|
1888
|
+
email: { $ifNull: [ '$userInfo.email', '' ] },
|
|
1889
|
+
type: { $ifNull: [ { $cond: [ { $eq: [ '$userInfo.userType', 'client' ] }, 'external', { $cond: [ { $eq: [ '$userInfo.userType', 'tango' ] }, 'internal', '' ] } ] }, '' ] },
|
|
1890
|
+
issueType: 1,
|
|
1891
|
+
status: 1,
|
|
1892
|
+
},
|
|
1893
|
+
},
|
|
1894
|
+
|
|
1895
|
+
];
|
|
1896
|
+
|
|
1897
|
+
if ( inputData?.filterIssue && inputData?.filterIssue != '' ) {
|
|
1898
|
+
const issueType = inputData.filterIssue == 'total' ? [ 'highcount', 'lowcount' ] : [ inputData.filterIssue ];
|
|
1899
|
+
filter.push( {
|
|
1900
|
+
issueType: { $in: issueType },
|
|
1901
|
+
} );
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
if ( inputData?.filterByStores && inputData?.filterByStores?.length > 0 ) {
|
|
1905
|
+
filter.push( {
|
|
1906
|
+
'basicDetails.storeId': { $in: inputData.filterByStores },
|
|
1907
|
+
} );
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
if ( inputData?.filterByStatus && inputData?.filterByStatus?.length > 0 ) {
|
|
1911
|
+
filter.push( {
|
|
1912
|
+
status: { $in: inputData.filterByStatus },
|
|
1913
|
+
} );
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
if ( inputData?.filterByQueryType && inputData?.filterByQueryType?.length > 0 ) {
|
|
1917
|
+
query.push( {
|
|
1918
|
+
$match: {
|
|
1919
|
+
type: { $in: inputData.filterByQueryType },
|
|
1920
|
+
},
|
|
1921
|
+
} );
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
1925
|
+
filter.push( {
|
|
1926
|
+
|
|
1927
|
+
$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' } },
|
|
1931
|
+
{ 'status': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1932
|
+
{ 'ticketId': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1933
|
+
{ 'issueType': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1934
|
+
],
|
|
1935
|
+
|
|
1936
|
+
} );
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
if ( inputData.sortColumName ) {
|
|
1940
|
+
const sortBy = inputData.sortBy || -1;
|
|
1941
|
+
query.push( {
|
|
1942
|
+
$sort: {
|
|
1943
|
+
[inputData.sortColumName == 'storeId' ? 'basicDetails.storeId' :
|
|
1944
|
+
inputData.sortColumName == 'clientName' ? 'basicDetails.clientName' :
|
|
1945
|
+
inputData.sortColumName == 'storeName' ? 'basicDetails.storeName' : inputData.sortColumName]: sortBy,
|
|
1946
|
+
},
|
|
1947
|
+
} );
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
const count = await aggregateTangoTicket( query );
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
query.push(
|
|
1954
|
+
{ $skip: offset },
|
|
1955
|
+
{ $limit: limit },
|
|
1956
|
+
);
|
|
1957
|
+
const result = await aggregateTangoTicket( query );
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
if ( inputData.export ) {
|
|
1961
|
+
const resultChunk = await chunkArray( count, 10 );
|
|
1962
|
+
const promises = resultChunk.map( async ( chunk ) => {
|
|
1963
|
+
const list = [];
|
|
1964
|
+
for ( let i = 0; i < chunk.length; i++ ) {
|
|
1965
|
+
req.user.userType == 'tango' ?
|
|
1966
|
+
|
|
1967
|
+
list.push( {
|
|
1968
|
+
'Created Date': chunk[i]?.createdAt,
|
|
1969
|
+
'Issue Date': chunk[i]?.issueDate,
|
|
1970
|
+
'Ticket ID': chunk[i]?.ticketId,
|
|
1971
|
+
'Brand ID': chunk[i]?.clientId,
|
|
1972
|
+
'Brand Name': chunk[i]?.clientName,
|
|
1973
|
+
'Store ID': chunk[i]?.storeId,
|
|
1974
|
+
'Store Name': chunk[i]?.storeName,
|
|
1975
|
+
'User Name': chunk[i]?.userName,
|
|
1976
|
+
'User Email': chunk[i]?.email,
|
|
1977
|
+
'Issue Type': chunk[i]?.issueType,
|
|
1978
|
+
'Type': chunk[i]?.type,
|
|
1979
|
+
'Status': chunk[i]?.status,
|
|
1980
|
+
|
|
1981
|
+
} ) :
|
|
1982
|
+
list.push( {
|
|
1983
|
+
'Created Date': chunk[i]?.createdAt,
|
|
1984
|
+
'Issue Date': chunk[i]?.issueDate,
|
|
1985
|
+
'Ticket ID': chunk[i]?.clientName,
|
|
1986
|
+
'Store ID': chunk[i]?.storeId,
|
|
1987
|
+
'Store Name': chunk[i]?.storeName,
|
|
1988
|
+
'Issue Type': chunk[i]?.issueType,
|
|
1989
|
+
'Type': chunk[i]?.type,
|
|
1990
|
+
'Status': chunk[i]?.status,
|
|
1991
|
+
} );
|
|
1992
|
+
}
|
|
1993
|
+
return list;
|
|
1994
|
+
} );
|
|
1995
|
+
const temp = await Promise.all( promises );
|
|
1996
|
+
const exportResult = temp.flat();
|
|
1997
|
+
await download( exportResult, res );
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
return res.sendSuccess( { response: response[0]?.response || defaultValue, result: result, count: count.length } );
|
|
2002
|
+
} catch ( error ) {
|
|
2003
|
+
logger.error( { error: error, function: 'dataMismatchTable' } );
|
|
2004
|
+
res.sendError( 'Internal Server Error', 500 );
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
@@ -293,7 +293,6 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
293
293
|
for ( const obj of timeSlots ) {
|
|
294
294
|
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
295
295
|
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
296
|
-
|
|
297
296
|
let internetSpeedQuery = {
|
|
298
297
|
'size': 1,
|
|
299
298
|
'query': {
|
|
@@ -306,7 +305,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
306
305
|
},
|
|
307
306
|
{
|
|
308
307
|
'term': {
|
|
309
|
-
'
|
|
308
|
+
'storeId.keyword': req.body.storeId,
|
|
310
309
|
},
|
|
311
310
|
},
|
|
312
311
|
{
|
|
@@ -331,9 +330,9 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
331
330
|
],
|
|
332
331
|
};
|
|
333
332
|
let speedTest = await getOpenSearchData( 'edgeapp_systemlogs', internetSpeedQuery );
|
|
334
|
-
|
|
335
333
|
if ( speedTest.body.hits && speedTest.body.hits.hits.length > 0 && speedTest.body.hits.hits[0]._source ) {
|
|
336
|
-
|
|
334
|
+
const megabytes = bytesToMB( speedTest.body.hits.hits[0]._source.data.upload_Speed.split( '.' )[0] ).toFixed( 2 );
|
|
335
|
+
obj.Internetspeed = megabytes+ ' MB/sec';
|
|
337
336
|
} else {
|
|
338
337
|
obj.Internetspeed = '';
|
|
339
338
|
}
|
|
@@ -420,7 +419,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
420
419
|
},
|
|
421
420
|
{
|
|
422
421
|
'term': {
|
|
423
|
-
'
|
|
422
|
+
'storeId.keyword': req.body.storeId,
|
|
424
423
|
},
|
|
425
424
|
},
|
|
426
425
|
{
|
|
@@ -457,6 +456,9 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
457
456
|
return res.sendError( error, 500 );
|
|
458
457
|
}
|
|
459
458
|
}
|
|
459
|
+
function bytesToMB( bytes ) {
|
|
460
|
+
return bytes / ( 1024 * 1024 );
|
|
461
|
+
}
|
|
460
462
|
function generateTimeSlots( startHour, endHour, interval, req ) {
|
|
461
463
|
try {
|
|
462
464
|
const timeSlots = [];
|
|
@@ -511,7 +513,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
511
513
|
},
|
|
512
514
|
{
|
|
513
515
|
'term': {
|
|
514
|
-
'
|
|
516
|
+
'storeId.keyword': req.body.storeId,
|
|
515
517
|
},
|
|
516
518
|
},
|
|
517
519
|
{
|
|
@@ -572,6 +574,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
572
574
|
],
|
|
573
575
|
};
|
|
574
576
|
const appQuitTime = await getOpenSearchData( 'edgeapp_systemlogs', appQuitTimeQuery );
|
|
577
|
+
|
|
575
578
|
let appCrashTimeQuery = {
|
|
576
579
|
'size': 1,
|
|
577
580
|
'query': {
|
|
@@ -621,7 +624,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
621
624
|
},
|
|
622
625
|
{
|
|
623
626
|
'term': {
|
|
624
|
-
'
|
|
627
|
+
'storeId.keyword': req.body.storeId,
|
|
625
628
|
},
|
|
626
629
|
},
|
|
627
630
|
{
|
|
@@ -724,7 +727,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
724
727
|
},
|
|
725
728
|
{
|
|
726
729
|
'term': {
|
|
727
|
-
'
|
|
730
|
+
'storeId.keyword': req.body.storeId,
|
|
728
731
|
},
|
|
729
732
|
},
|
|
730
733
|
{
|
|
@@ -995,7 +998,6 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
995
998
|
|
|
996
999
|
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
997
1000
|
if ( streamwiseDowntime.length > 0 ) {
|
|
998
|
-
console.log( streamwiseDowntime );
|
|
999
1001
|
for ( let stream of streamwiseDowntime ) {
|
|
1000
1002
|
if ( stream.stream === req.body.stream ) {
|
|
1001
1003
|
obj.downTime= stream.down_time;
|
|
@@ -157,6 +157,7 @@ export async function userTicketList( req, res ) {
|
|
|
157
157
|
$project: {
|
|
158
158
|
storeId: '$basicDetails.storeId',
|
|
159
159
|
storeName: '$basicDetails.storeName',
|
|
160
|
+
clientId: '$basicDetails.clientId',
|
|
160
161
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
161
162
|
updatedAt: 1,
|
|
162
163
|
ticketId: 1,
|
|
@@ -190,6 +191,7 @@ export async function userTicketList( req, res ) {
|
|
|
190
191
|
storeId: 1,
|
|
191
192
|
storeName: 1,
|
|
192
193
|
updatedAt: 1,
|
|
194
|
+
clientId: 1,
|
|
193
195
|
Date: 1,
|
|
194
196
|
ticketId: 1,
|
|
195
197
|
issueStatus: 1,
|
|
@@ -206,6 +208,7 @@ export async function userTicketList( req, res ) {
|
|
|
206
208
|
_id: '$ticketId',
|
|
207
209
|
storeId: { $first: '$storeId' },
|
|
208
210
|
storeName: { $first: '$storeName' },
|
|
211
|
+
clientId: { $first: '$clientId' },
|
|
209
212
|
updatedAt: { $first: '$updatedAt' },
|
|
210
213
|
Date: { $first: '$Date' },
|
|
211
214
|
ticketId: { $first: '$ticketId' },
|
|
@@ -753,3 +756,55 @@ export async function storeInfraList( req, res ) {
|
|
|
753
756
|
return res.sendError( error, 500 );
|
|
754
757
|
}
|
|
755
758
|
}
|
|
759
|
+
export async function pendingTicket( req, res ) {
|
|
760
|
+
try {
|
|
761
|
+
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
762
|
+
let countQuery=[
|
|
763
|
+
{
|
|
764
|
+
$match: {
|
|
765
|
+
$and: [
|
|
766
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
767
|
+
{ createdAt: { $lte: date.end } },
|
|
768
|
+
],
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
$project: {
|
|
773
|
+
issueType: 1,
|
|
774
|
+
installationCount: {
|
|
775
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'installation' ] }, { $ne: [ '$status', 'closed' ] }, { $eq: [ '$ticketDetails.issueStatus', 'notidentified' ] } ] }, 1, 0,
|
|
776
|
+
],
|
|
777
|
+
},
|
|
778
|
+
infraCount: {
|
|
779
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'infra' ] }, { $ne: [ '$status', 'closed' ] }, { $eq: [ '$ticketDetails.issueStatus', 'notidentified' ] } ] }, 1, 0,
|
|
780
|
+
],
|
|
781
|
+
},
|
|
782
|
+
datamismatchCount: {
|
|
783
|
+
$cond: [ { $and: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, { $eq: [ '$status', 'closed' ] } ] }, 1, 0,
|
|
784
|
+
],
|
|
785
|
+
},
|
|
786
|
+
matCount: {
|
|
787
|
+
$cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] }, { $eq: [ '$status', 'open' ] } ] }, 1, 0,
|
|
788
|
+
],
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
$group: {
|
|
794
|
+
_id: null,
|
|
795
|
+
installationCount: { $sum: '$installationCount' },
|
|
796
|
+
infraCount: { $sum: '$infraCount' },
|
|
797
|
+
datamismatchCount: { $sum: '$datamismatchCount' },
|
|
798
|
+
matCount: { $sum: '$matCount' },
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
];
|
|
804
|
+
let result = await aggregateTangoTicket( countQuery );
|
|
805
|
+
res.sendSuccess( result );
|
|
806
|
+
} catch ( error ) {
|
|
807
|
+
logger.error( { error: error, function: 'pendingTicket' } );
|
|
808
|
+
return res.sendError( error, 500 );
|
|
809
|
+
}
|
|
810
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
4
|
-
import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
|
|
4
|
+
import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores, ticketCountSplit, overViewTable, ticketCount } from '../controllers/clientInfra.controller.js';
|
|
5
5
|
|
|
6
6
|
export const clientInfraRouter = express.Router();
|
|
7
7
|
|
|
@@ -31,4 +31,15 @@ clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, authoriz
|
|
|
31
31
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
32
32
|
} ), hourWiseDownstores );
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
clientInfraRouter.post( '/ticket-count', isAllowedSessionHandler, authorize( {
|
|
35
|
+
userType: [ 'client', 'tango' ], access: [
|
|
36
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
37
|
+
} ), ticketCount );
|
|
38
|
+
clientInfraRouter.post( '/ticket-count-split', isAllowedSessionHandler, authorize( {
|
|
39
|
+
userType: [ 'client', 'tango' ], access: [
|
|
40
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
41
|
+
} ), ticketCountSplit );
|
|
42
|
+
clientInfraRouter.post( '/overview-table', isAllowedSessionHandler, authorize( {
|
|
43
|
+
userType: [ 'client', 'tango' ], access: [
|
|
44
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
45
|
+
} ), overViewTable );
|
|
@@ -4,7 +4,7 @@ import { isAllowedSessionHandler, authorize, validate } from 'tango-app-api-midd
|
|
|
4
4
|
import { validateDetails, bulkvalidateDetails, validateTicket, bulkvalidateTicket, validateTicketstatus, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
5
5
|
import { createTicket, bulkcreateTicket, updateStatus, createReason, PrimaryReasons, matTable, removeAttachment,
|
|
6
6
|
secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply, uploadAttachments, getInfraIssues,
|
|
7
|
-
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, infraTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
7
|
+
updateInstallationTicket, emailUserList, saveInfraEmailConfig, invoice, allCounts, infraTable, dataMismatchTable, storeFilter, assignTicket, installationTable } from '../controllers/infra.controllers.js';
|
|
8
8
|
import { getInfraIssueValid } from '../dtos/infra.dtos.js';
|
|
9
9
|
|
|
10
10
|
|
|
@@ -60,6 +60,10 @@ infraRouter.post( '/saveInfraEmailConfig', isAllowedSessionHandler, authorize( {
|
|
|
60
60
|
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit', 'isView' ] } ],
|
|
61
61
|
} ), saveInfraEmailConfig );
|
|
62
62
|
infraRouter.post( '/invoice', invoice );
|
|
63
|
+
infraRouter.post( '/allCounts', isAllowedSessionHandler, authorize( {
|
|
64
|
+
userType: [ 'client', 'tango' ], access: [
|
|
65
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
66
|
+
} ), allCounts );
|
|
63
67
|
infraRouter.post( '/infraTable', isAllowedSessionHandler, authorize( {
|
|
64
68
|
userType: [ 'client', 'tango' ], access: [
|
|
65
69
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
@@ -72,6 +76,10 @@ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
|
|
|
72
76
|
userType: [ 'client', 'tango' ], access: [
|
|
73
77
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
74
78
|
} ), matTable );
|
|
79
|
+
infraRouter.post( '/dataMismatchTable', isAllowedSessionHandler, authorize( {
|
|
80
|
+
userType: [ 'client', 'tango' ], access: [
|
|
81
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
82
|
+
} ), dataMismatchTable );
|
|
75
83
|
infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
|
|
76
84
|
userType: [ 'client', 'tango' ], access: [
|
|
77
85
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
3
|
-
import { userTakeTicket, userTicketList, activeTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
3
|
+
import { userTakeTicket, userTicketList, activeTicketList, basicDetails, workHistory, pendingTicket, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
4
4
|
|
|
5
5
|
export const userInfraRouter = express.Router();
|
|
6
6
|
|
|
@@ -30,5 +30,9 @@ userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, authorize( {
|
|
|
30
30
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] },
|
|
31
31
|
],
|
|
32
32
|
} ), storeInfraList );
|
|
33
|
-
|
|
33
|
+
userInfraRouter.post( '/pendingTicket', isAllowedSessionHandler, authorize( {
|
|
34
|
+
userType: [ 'tango', 'client' ], access: [
|
|
35
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] },
|
|
36
|
+
],
|
|
37
|
+
} ), pendingTicket );
|
|
34
38
|
|