tango-app-api-infra 3.0.94-dev → 3.0.97-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.97-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
|
} );
|
|
@@ -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,
|
|
@@ -346,6 +345,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
346
345
|
clientId: '$basicDetails.clientId',
|
|
347
346
|
ticketId: 1,
|
|
348
347
|
storeName: '$basicDetails.storeName',
|
|
348
|
+
clientName: '$basicDetails.clientName',
|
|
349
349
|
status: 1,
|
|
350
350
|
createdAt: 1,
|
|
351
351
|
issueIdentifiedDate: '$ticketDetails.issueIdentifiedDate',
|
|
@@ -381,6 +381,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
381
381
|
storeName: 1,
|
|
382
382
|
createdAt: 1,
|
|
383
383
|
ticketId: 1,
|
|
384
|
+
clientName: 1,
|
|
384
385
|
actionBy: '$primaryIssue.actionBy',
|
|
385
386
|
issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '' ] },
|
|
386
387
|
issueClosedDate: { $ifNull: [ '$issueClosedDate', '' ] },
|
|
@@ -397,6 +398,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
397
398
|
ticketId: { $first: '$ticketId' },
|
|
398
399
|
actionBy: { $first: '$actionBy' },
|
|
399
400
|
storeName: { $first: '$storeName' },
|
|
401
|
+
clientName: { $first: '$clientName' },
|
|
400
402
|
createdAt: { $first: '$createdAt' },
|
|
401
403
|
issueIdentifiedDate: { $last: '$issueIdentifiedDate' },
|
|
402
404
|
issueClosedDate: { $last: '$issueClosedDate' },
|
|
@@ -513,13 +515,13 @@ export async function infraIssuesTable( req, res ) {
|
|
|
513
515
|
const exportdata = [];
|
|
514
516
|
result.forEach( ( element ) => {
|
|
515
517
|
exportdata.push( {
|
|
516
|
-
'
|
|
517
|
-
'
|
|
518
|
-
'
|
|
519
|
-
'
|
|
520
|
-
'
|
|
521
|
-
'
|
|
522
|
-
'
|
|
518
|
+
'Created On': element.createdAt,
|
|
519
|
+
'StoreID': element.storeId,
|
|
520
|
+
'StoreName': element.storeName,
|
|
521
|
+
'Primary Issue': element.primaryIssue,
|
|
522
|
+
'Sub Issue': element.secondaryIssue,
|
|
523
|
+
'Issue Identified on': element.issueIdentifiedDate? dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ):'',
|
|
524
|
+
'Status': element.status,
|
|
523
525
|
} );
|
|
524
526
|
} );
|
|
525
527
|
await download( exportdata, res );
|
|
@@ -547,7 +549,6 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
547
549
|
$and: [
|
|
548
550
|
{ issueType: 'installation' },
|
|
549
551
|
{ 'status': { $ne: 'closed' } },
|
|
550
|
-
|
|
551
552
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
552
553
|
{ createdAt: { $lte: date.end } },
|
|
553
554
|
],
|
|
@@ -559,6 +560,9 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
559
560
|
if ( req.body.installtionfilterIssue == 'installFailedStores' ) {
|
|
560
561
|
query.push( { $match: { 'ticketDetails.issueStatus': 'identified' } } );
|
|
561
562
|
}
|
|
563
|
+
if ( req.body.installtionfilterIssue == 'installedStores' ) {
|
|
564
|
+
query.push( { $match: { 'ticketDetails.issueStatus': 'notidentified' } } );
|
|
565
|
+
}
|
|
562
566
|
query.push( {
|
|
563
567
|
$project: {
|
|
564
568
|
createdAt: 1,
|
|
@@ -624,11 +628,16 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
624
628
|
);
|
|
625
629
|
}
|
|
626
630
|
if ( req.body.installtionfilterIssue == 'installedStores' ) {
|
|
631
|
+
let pendingstorecount = await aggregateTangoTicket( query );
|
|
632
|
+
let ticketStore = [];
|
|
633
|
+
for ( let store of pendingstorecount ) {
|
|
634
|
+
ticketStore.push( store.storeId );
|
|
635
|
+
}
|
|
627
636
|
storesQuery.push( {
|
|
628
637
|
$match: {
|
|
629
638
|
'$and': [
|
|
630
639
|
{ 'clientId': { $in: req.body.clientId } },
|
|
631
|
-
{ '
|
|
640
|
+
{ 'storeId': { $nin: ticketStore } },
|
|
632
641
|
{ 'status': 'active' },
|
|
633
642
|
{ 'createdAt': { $lte: date.end } },
|
|
634
643
|
],
|
|
@@ -752,10 +761,10 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
752
761
|
const exportdata = [];
|
|
753
762
|
storesList.forEach( ( element ) => {
|
|
754
763
|
exportdata.push( {
|
|
755
|
-
'
|
|
756
|
-
'
|
|
757
|
-
'
|
|
758
|
-
'
|
|
764
|
+
'Client Name': element.clientName,
|
|
765
|
+
'Store ID': element.storeId,
|
|
766
|
+
'Store Name': element.storeName,
|
|
767
|
+
'Status': element.status,
|
|
759
768
|
} );
|
|
760
769
|
} );
|
|
761
770
|
await download( exportdata, res );
|
|
@@ -1211,6 +1220,9 @@ export async function ticketCountSplit( req, res ) {
|
|
|
1211
1220
|
{ issueType: { $in: [ 'highcount', 'lowcount' ] } },
|
|
1212
1221
|
|
|
1213
1222
|
];
|
|
1223
|
+
if ( req.user.userType === 'client' ) {
|
|
1224
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1225
|
+
}
|
|
1214
1226
|
if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
|
|
1215
1227
|
filter.push( {
|
|
1216
1228
|
issueType: { $in: inputData.issueType },
|
|
@@ -1285,13 +1297,20 @@ export async function overViewTable( req, res ) {
|
|
|
1285
1297
|
{
|
|
1286
1298
|
'basicDetails.clientId': { $in: inputData.clientId },
|
|
1287
1299
|
},
|
|
1288
|
-
|
|
1289
1300
|
];
|
|
1301
|
+
if ( req.user.userType === 'client' ) {
|
|
1302
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1303
|
+
}
|
|
1290
1304
|
if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
|
|
1291
1305
|
filter.push( {
|
|
1292
1306
|
issueType: { $in: inputData.issueType },
|
|
1293
1307
|
} );
|
|
1294
1308
|
}
|
|
1309
|
+
if ( inputData?.status && inputData?.status!='' ) {
|
|
1310
|
+
filter.push( {
|
|
1311
|
+
status: inputData?.status,
|
|
1312
|
+
} );
|
|
1313
|
+
}
|
|
1295
1314
|
const query = [
|
|
1296
1315
|
{
|
|
1297
1316
|
$match: {
|
|
@@ -1314,23 +1333,18 @@ export async function overViewTable( req, res ) {
|
|
|
1314
1333
|
];
|
|
1315
1334
|
if ( inputData.searchValue ) {
|
|
1316
1335
|
filter.push( {
|
|
1317
|
-
|
|
1318
1336
|
$or: [
|
|
1319
|
-
{ '
|
|
1320
|
-
{ '
|
|
1321
|
-
{ '
|
|
1337
|
+
{ 'clientName': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1338
|
+
{ 'storeId': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1339
|
+
{ 'storeName': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1322
1340
|
{ 'status': { $regex: req.body.searchValue, $options: 'i' } },
|
|
1323
1341
|
],
|
|
1324
|
-
|
|
1325
1342
|
} );
|
|
1326
1343
|
}
|
|
1327
|
-
if ( inputData.
|
|
1344
|
+
if ( inputData.sortColumnName ) {
|
|
1328
1345
|
const sortBy = inputData.sortBy || -1;
|
|
1329
1346
|
query.push( {
|
|
1330
|
-
$sort: {
|
|
1331
|
-
[inputData.sortColumName == 'storeId' ? 'basicDetails.storeId' :
|
|
1332
|
-
inputData.sortColumName == 'clientName' ? 'basicDetails.clientName' :
|
|
1333
|
-
inputData.sortColumName == 'storeName' ? 'basicDetails.storeName' : inputData.sortColumName]: sortBy,
|
|
1347
|
+
$sort: { [inputData.sortColumnName]: sortBy,
|
|
1334
1348
|
},
|
|
1335
1349
|
} );
|
|
1336
1350
|
}
|
|
@@ -1348,22 +1362,16 @@ export async function overViewTable( req, res ) {
|
|
|
1348
1362
|
return res.sendError( 'No Data Found', 204 );
|
|
1349
1363
|
}
|
|
1350
1364
|
if ( inputData.isExport ) {
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
'Status': chunk[i]?.status,
|
|
1360
|
-
} );
|
|
1361
|
-
}
|
|
1362
|
-
return list;
|
|
1365
|
+
const exportdata = [];
|
|
1366
|
+
count.forEach( ( element ) => {
|
|
1367
|
+
exportdata.push( {
|
|
1368
|
+
'ClientName': element.clientName,
|
|
1369
|
+
'Store ID': element.storeId,
|
|
1370
|
+
'Store Name': element.storeName,
|
|
1371
|
+
'Status': element.status,
|
|
1372
|
+
} );
|
|
1363
1373
|
} );
|
|
1364
|
-
|
|
1365
|
-
const exportResult = temp.flat();
|
|
1366
|
-
await download( exportResult, res );
|
|
1374
|
+
await download( exportdata, res );
|
|
1367
1375
|
return;
|
|
1368
1376
|
}
|
|
1369
1377
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
@@ -1383,6 +1391,10 @@ export async function ticketCount( req, res ) {
|
|
|
1383
1391
|
},
|
|
1384
1392
|
|
|
1385
1393
|
];
|
|
1394
|
+
|
|
1395
|
+
if ( req.user.userType === 'client' ) {
|
|
1396
|
+
filter.push( { 'dataMismatch.showToClient': true } );
|
|
1397
|
+
}
|
|
1386
1398
|
if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
|
|
1387
1399
|
filter.push( {
|
|
1388
1400
|
'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';
|
|
@@ -170,6 +193,14 @@ export async function activityList( req, res ) {
|
|
|
170
193
|
},
|
|
171
194
|
);
|
|
172
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
|
+
}
|
|
203
|
+
|
|
173
204
|
if ( req.body.filter && req.body.filter !== '' ) {
|
|
174
205
|
query.push( {
|
|
175
206
|
$match: {
|