tango-app-api-infra 3.0.93-dev → 3.0.95-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.
|
|
3
|
+
"version": "3.0.95-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"mongodb": "^6.4.0",
|
|
27
27
|
"nodemon": "^3.1.0",
|
|
28
28
|
"swagger-ui-express": "^5.0.0",
|
|
29
|
-
"tango-api-schema": "^2.0.
|
|
29
|
+
"tango-api-schema": "^2.0.113",
|
|
30
30
|
"tango-app-api-middleware": "^1.0.73-test",
|
|
31
31
|
"winston": "^3.12.0",
|
|
32
32
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -187,7 +187,6 @@ export async function installationCard( req, res ) {
|
|
|
187
187
|
} );
|
|
188
188
|
let installedCount = await countDocumentsStore( {
|
|
189
189
|
'clientId': { $in: req.body.clientId },
|
|
190
|
-
'edge.firstFile': true,
|
|
191
190
|
'status': 'active',
|
|
192
191
|
'createdAt': { $lte: date.end },
|
|
193
192
|
} );
|
|
@@ -204,7 +203,7 @@ export async function installationCard( req, res ) {
|
|
|
204
203
|
{ 'status': { $ne: 'closed' } },
|
|
205
204
|
{ 'ticketDetails.issueStatus': 'notidentified' },
|
|
206
205
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
207
|
-
{ createdAt: { $lte:
|
|
206
|
+
{ createdAt: { $lte: date.end } },
|
|
208
207
|
],
|
|
209
208
|
},
|
|
210
209
|
},
|
|
@@ -216,7 +215,7 @@ export async function installationCard( req, res ) {
|
|
|
216
215
|
{ 'status': { $ne: 'closed' } },
|
|
217
216
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
218
217
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
219
|
-
{ createdAt: { $lte:
|
|
218
|
+
{ createdAt: { $lte: date.end } },
|
|
220
219
|
],
|
|
221
220
|
},
|
|
222
221
|
},
|
|
@@ -290,7 +289,7 @@ export async function installationCard( req, res ) {
|
|
|
290
289
|
res.sendSuccess( {
|
|
291
290
|
onboardedStoresCount: onboardedCount,
|
|
292
291
|
inactiveStoresCount: deactiveCount,
|
|
293
|
-
installedStoresCount: installedCount,
|
|
292
|
+
installedStoresCount: installedCount-yettoInstallCount.length,
|
|
294
293
|
yettoInstallCount: yettoInstallCount.length,
|
|
295
294
|
installFailedCount: installFailedCount.length,
|
|
296
295
|
infraIssues: response,
|
|
@@ -547,9 +546,8 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
547
546
|
$and: [
|
|
548
547
|
{ issueType: 'installation' },
|
|
549
548
|
{ 'status': { $ne: 'closed' } },
|
|
550
|
-
|
|
551
549
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
552
|
-
{ createdAt: { $lte:
|
|
550
|
+
{ createdAt: { $lte: date.end } },
|
|
553
551
|
],
|
|
554
552
|
},
|
|
555
553
|
} );
|
|
@@ -559,6 +557,9 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
559
557
|
if ( req.body.installtionfilterIssue == 'installFailedStores' ) {
|
|
560
558
|
query.push( { $match: { 'ticketDetails.issueStatus': 'identified' } } );
|
|
561
559
|
}
|
|
560
|
+
if ( req.body.installtionfilterIssue == 'installedStores' ) {
|
|
561
|
+
query.push( { $match: { 'ticketDetails.issueStatus': 'notidentified' } } );
|
|
562
|
+
}
|
|
562
563
|
query.push( {
|
|
563
564
|
$project: {
|
|
564
565
|
createdAt: 1,
|
|
@@ -624,11 +625,16 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
624
625
|
);
|
|
625
626
|
}
|
|
626
627
|
if ( req.body.installtionfilterIssue == 'installedStores' ) {
|
|
628
|
+
let pendingstorecount = await aggregateTangoTicket( query );
|
|
629
|
+
let ticketStore = [];
|
|
630
|
+
for ( let store of pendingstorecount ) {
|
|
631
|
+
ticketStore.push( store.storeId );
|
|
632
|
+
}
|
|
627
633
|
storesQuery.push( {
|
|
628
634
|
$match: {
|
|
629
635
|
'$and': [
|
|
630
636
|
{ 'clientId': { $in: req.body.clientId } },
|
|
631
|
-
{ '
|
|
637
|
+
{ 'storeId': { $nin: ticketStore } },
|
|
632
638
|
{ 'status': 'active' },
|
|
633
639
|
{ 'createdAt': { $lte: date.end } },
|
|
634
640
|
],
|
|
@@ -1211,6 +1217,9 @@ export async function ticketCountSplit( req, res ) {
|
|
|
1211
1217
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1212
1218
|
|
|
1213
1219
|
];
|
|
1220
|
+
if ( req.user.userType === 'client' ) {
|
|
1221
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1222
|
+
}
|
|
1214
1223
|
if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
|
|
1215
1224
|
filter.push( {
|
|
1216
1225
|
issueType: { $in: inputData.issueType },
|
|
@@ -1285,13 +1294,20 @@ export async function overViewTable( req, res ) {
|
|
|
1285
1294
|
{
|
|
1286
1295
|
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1287
1296
|
},
|
|
1288
|
-
|
|
1289
1297
|
];
|
|
1298
|
+
if ( req.user.userType === 'client' ) {
|
|
1299
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1300
|
+
}
|
|
1290
1301
|
if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
|
|
1291
1302
|
filter.push( {
|
|
1292
1303
|
issueType: { $in: inputData.issueType },
|
|
1293
1304
|
} );
|
|
1294
1305
|
}
|
|
1306
|
+
if ( inputData?.status && inputData?.status!='' ) {
|
|
1307
|
+
filter.push( {
|
|
1308
|
+
status: inputData?.status,
|
|
1309
|
+
} );
|
|
1310
|
+
}
|
|
1295
1311
|
const query = [
|
|
1296
1312
|
{
|
|
1297
1313
|
$match: {
|
|
@@ -1383,6 +1399,10 @@ export async function ticketCount( req, res ) {
|
|
|
1383
1399
|
},
|
|
1384
1400
|
|
|
1385
1401
|
];
|
|
1402
|
+
|
|
1403
|
+
if ( req.user.userType === 'client' ) {
|
|
1404
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1405
|
+
}
|
|
1386
1406
|
if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
|
|
1387
1407
|
filter.push( {
|
|
1388
1408
|
'basicDetails.clientId': { $in: inputData.clientId },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
|
-
import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
|
|
6
6
|
export async function createTicket( req, res ) {
|
|
@@ -8,8 +8,31 @@ 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.
|
|
11
|
+
return res.sendError( 'Ticket Already Exists for the store', 400 );
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
if ( req.body.issueType === 'highcount' ) {
|
|
15
|
+
let param = {
|
|
16
|
+
Bucket: appConfig.cloud.aws.bucket.auditInput,
|
|
17
|
+
file_path: `${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/${req.body.storeId}/`,
|
|
18
|
+
MaxKeys: 1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
param.Bucket = appConfig.cloud.aws.bucket.auditOutput;
|
|
22
|
+
|
|
23
|
+
param.file_path = `${req.body.storeId}/${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/`;
|
|
24
|
+
|
|
25
|
+
const auditOutputData = await listFileByPath( param );
|
|
26
|
+
|
|
27
|
+
param.Bucket = appConfig.cloud.aws.bucket.edgeAppSource;
|
|
28
|
+
|
|
29
|
+
const edgeAppSource = await listFileByPath( param );
|
|
30
|
+
|
|
31
|
+
if ( !auditOutputData?.data?.length && !edgeAppSource?.data?.length ) {
|
|
32
|
+
return res.sendError( `No data available for ${req.body.basicDetails.storeName} on ${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}.`, 400 );
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
13
36
|
let actionBy = '';
|
|
14
37
|
if ( req.user.userType == 'tango' ) {
|
|
15
38
|
actionBy = 'Tango';
|
|
@@ -21,6 +44,7 @@ export async function createTicket( req, res ) {
|
|
|
21
44
|
actualCount: req.body.actualCount,
|
|
22
45
|
expectedCount: req.body.expectedCount,
|
|
23
46
|
contactEmail: req.body.contactEmail,
|
|
47
|
+
showToClient: req.body.showToClient,
|
|
24
48
|
};
|
|
25
49
|
req.body.issueDate = new Date( req.body.Date );
|
|
26
50
|
req.body.ticketId = 'TE_DM_' + new Date().valueOf();
|
|
@@ -106,17 +130,31 @@ export async function updateMat( req, res ) {
|
|
|
106
130
|
export async function activityList( req, res ) {
|
|
107
131
|
try {
|
|
108
132
|
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
|
-
|
|
133
|
+
let query = [ ];
|
|
134
|
+
if ( req.body.fromDate == req.body.toDate ) {
|
|
135
|
+
query.push( {
|
|
136
|
+
$match: {
|
|
137
|
+
$and: [
|
|
138
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
139
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
140
|
+
{ createdAt: { $lte: date.end } },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
} );
|
|
144
|
+
} else {
|
|
145
|
+
query.push( {
|
|
146
|
+
$match: {
|
|
147
|
+
$and: [
|
|
148
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
149
|
+
{ issueType: { $in: [ 'lowcount', 'highcount' ] } },
|
|
150
|
+
{ createdAt: { $gte: date.start } },
|
|
151
|
+
{ createdAt: { $lte: date.end } },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
} );
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
query.push( {
|
|
120
158
|
$project: {
|
|
121
159
|
storeId: '$basicDetails.storeId',
|
|
122
160
|
status: 1,
|
|
@@ -153,7 +191,15 @@ export async function activityList( req, res ) {
|
|
|
153
191
|
issueDate: -1,
|
|
154
192
|
},
|
|
155
193
|
},
|
|
156
|
-
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
if ( req.user.userType === 'client' ) {
|
|
197
|
+
query.forEach( ( e ) => {
|
|
198
|
+
if ( e.$match ) {
|
|
199
|
+
$match.$and.push( { 'dataMismatch.showToClient': true } );
|
|
200
|
+
}
|
|
201
|
+
} );
|
|
202
|
+
}
|
|
157
203
|
|
|
158
204
|
if ( req.body.filter && req.body.filter !== '' ) {
|
|
159
205
|
query.push( {
|
|
@@ -1746,3 +1746,261 @@ export async function storeFilter( req, res ) {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
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
|
+
};
|
|
@@ -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' },
|
|
@@ -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, allCounts, 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
|
|
|
@@ -76,6 +76,10 @@ infraRouter.post( '/matTable', isAllowedSessionHandler, authorize( {
|
|
|
76
76
|
userType: [ 'client', 'tango' ], access: [
|
|
77
77
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
78
78
|
} ), matTable );
|
|
79
|
+
infraRouter.post( '/dataMismatchTable', isAllowedSessionHandler, authorize( {
|
|
80
|
+
userType: [ 'client', 'tango' ], access: [
|
|
81
|
+
{ featureName: 'manage', name: 'tickets', permissions: [ 'isView' ] } ],
|
|
82
|
+
} ), dataMismatchTable );
|
|
79
83
|
infraRouter.post( '/assignTicket', isAllowedSessionHandler, authorize( {
|
|
80
84
|
userType: [ 'client', 'tango' ], access: [
|
|
81
85
|
{ featureName: 'manage', name: 'tickets', permissions: [ 'isEdit', 'isView' ] } ],
|