tango-app-api-infra 3.1.13 → 3.1.15
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 +3 -3
- package/src/controllers/clientInfra.controller.js +110 -29
- package/src/controllers/employeeTraning.controller.js +1 -1
- package/src/controllers/infra.controllers.js +214 -25
- package/src/controllers/internalInfra.controller.js +19 -13
- package/src/controllers/storeInfra.controlller.js +285 -55
- package/src/controllers/userInfra.controller.js +26 -24
- package/src/routes/infra.routes.js +5 -1
- package/src/routes/storeInfra.routes.js +9 -1
- package/src/services/tangoTicket.service.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.15",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,8 +26,8 @@
|
|
|
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.
|
|
30
|
-
"tango-app-api-middleware": "^3.1.
|
|
29
|
+
"tango-api-schema": "^2.0.104",
|
|
30
|
+
"tango-app-api-middleware": "^3.1.11",
|
|
31
31
|
"winston": "^3.12.0",
|
|
32
32
|
"winston-daily-rotate-file": "^5.0.0"
|
|
33
33
|
},
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { countDocumentsStore } from '../services/store.service.js';
|
|
3
3
|
import { logger, download, getUTC } from 'tango-app-api-middleware';
|
|
4
4
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
5
5
|
import { findinfraReason } from '../services/infraReason.service.js';
|
|
6
|
-
import { aggregateClient } from '../services/client.service.js';
|
|
6
|
+
import { aggregateClient, findClient } from '../services/client.service.js';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
import { getOpenSearchData } from 'tango-app-api-middleware';
|
|
9
9
|
|
|
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 }, 'edge.firstFile': true, 'status': 'active' } );
|
|
13
|
+
let storeCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'createdAt': { $lte: date.end }, 'edge.firstFile': true, 'status': 'active' } );
|
|
14
14
|
let infraStoreCount = await aggregateTangoTicket( [
|
|
15
15
|
{
|
|
16
16
|
$match: {
|
|
@@ -18,7 +18,7 @@ export async function infraCard( req, res ) {
|
|
|
18
18
|
{ issueType: 'infra' },
|
|
19
19
|
{ status: { $ne: 'closed' } },
|
|
20
20
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
21
|
-
{ createdAt: { $gte: date.start } },
|
|
21
|
+
// { createdAt: { $gte: date.start } },
|
|
22
22
|
{ createdAt: { $lte: date.end } },
|
|
23
23
|
],
|
|
24
24
|
},
|
|
@@ -54,7 +54,7 @@ export async function infraCard( req, res ) {
|
|
|
54
54
|
{ status: { $ne: 'closed' } },
|
|
55
55
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
56
56
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
57
|
-
{ createdAt: { $gte: date.start } },
|
|
57
|
+
// { createdAt: { $gte: date.start } },
|
|
58
58
|
{ createdAt: { $lte: date.end } },
|
|
59
59
|
],
|
|
60
60
|
},
|
|
@@ -134,6 +134,19 @@ export async function infraCard( req, res ) {
|
|
|
134
134
|
count: 0,
|
|
135
135
|
} ) );
|
|
136
136
|
}
|
|
137
|
+
|
|
138
|
+
response.unshift( {
|
|
139
|
+
name: 'Identified Issues',
|
|
140
|
+
count: infraStoreCount.length > 0 ? infraStoreCount[0].identifiedcount : 0,
|
|
141
|
+
} );
|
|
142
|
+
response.unshift( {
|
|
143
|
+
name: 'All Issues',
|
|
144
|
+
count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount : 0,
|
|
145
|
+
} );
|
|
146
|
+
response.push( {
|
|
147
|
+
name: 'Issues Not Identified',
|
|
148
|
+
count: infraStoreCount.length > 0 ? infraStoreCount[0].infraCount - infraStoreCount[0].identifiedcount : 0,
|
|
149
|
+
} );
|
|
137
150
|
res.sendSuccess( {
|
|
138
151
|
total: storeCount,
|
|
139
152
|
liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount : 0,
|
|
@@ -149,15 +162,21 @@ export async function infraCard( req, res ) {
|
|
|
149
162
|
}
|
|
150
163
|
export async function installationCard( req, res ) {
|
|
151
164
|
try {
|
|
165
|
+
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
152
166
|
let onboardedCount = await countDocumentsStore( {
|
|
153
167
|
'$and': [
|
|
154
168
|
{ 'clientId': { $in: req.body.clientId } },
|
|
169
|
+
{ 'createdAt': { $lte: date.end } },
|
|
155
170
|
],
|
|
156
171
|
} );
|
|
157
|
-
let installedCount = await countDocumentsStore( {
|
|
158
|
-
'
|
|
159
|
-
|
|
160
|
-
|
|
172
|
+
let installedCount = await countDocumentsStore( {
|
|
173
|
+
'clientId': { $in: req.body.clientId },
|
|
174
|
+
'edge.firstFile': true, 'status': 'active', 'createdAt': { $lte: date.end },
|
|
175
|
+
} );
|
|
176
|
+
let deactiveCount = await countDocumentsStore( {
|
|
177
|
+
'clientId': { $in: req.body.clientId },
|
|
178
|
+
'status': 'deactive',
|
|
179
|
+
} );
|
|
161
180
|
let yettoInstallCount = await aggregateTangoTicket( [
|
|
162
181
|
{
|
|
163
182
|
$match: {
|
|
@@ -166,7 +185,7 @@ export async function installationCard( req, res ) {
|
|
|
166
185
|
{ 'status': { $ne: 'closed' } },
|
|
167
186
|
{ 'ticketDetails.issueStatus': 'notidentified' },
|
|
168
187
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
169
|
-
{ createdAt: { $
|
|
188
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
170
189
|
],
|
|
171
190
|
},
|
|
172
191
|
},
|
|
@@ -178,7 +197,7 @@ export async function installationCard( req, res ) {
|
|
|
178
197
|
{ 'status': { $ne: 'closed' } },
|
|
179
198
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
180
199
|
{ 'ticketDetails.issueStatus': 'identified' },
|
|
181
|
-
{ createdAt: { $
|
|
200
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
182
201
|
],
|
|
183
202
|
},
|
|
184
203
|
},
|
|
@@ -265,14 +284,21 @@ export async function installationCard( req, res ) {
|
|
|
265
284
|
export async function infraIssuesTable( req, res ) {
|
|
266
285
|
try {
|
|
267
286
|
let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
|
|
287
|
+
let issueStatus = [ 'identified' ];
|
|
288
|
+
if ( req.body.filterIssue == 'Issues Not Identified' ) {
|
|
289
|
+
issueStatus = [ 'notidentified' ];
|
|
290
|
+
};
|
|
291
|
+
if ( req.body.filterIssue == 'All Issues' ) {
|
|
292
|
+
issueStatus = [ 'notidentified', 'identified' ];
|
|
293
|
+
};
|
|
268
294
|
let query = [ {
|
|
269
295
|
$match: {
|
|
270
296
|
$and: [
|
|
271
297
|
{ issueType: 'infra' },
|
|
272
298
|
{ status: { $ne: 'closed' } },
|
|
273
299
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
274
|
-
{ 'ticketDetails.issueStatus':
|
|
275
|
-
{ createdAt: { $gte: date.start } },
|
|
300
|
+
{ 'ticketDetails.issueStatus': { $in: issueStatus } },
|
|
301
|
+
// { createdAt: { $gte: date.start } },
|
|
276
302
|
{ createdAt: { $lte: date.end } },
|
|
277
303
|
],
|
|
278
304
|
},
|
|
@@ -343,7 +369,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
343
369
|
},
|
|
344
370
|
},
|
|
345
371
|
];
|
|
346
|
-
if ( req.body.filterIssue && req.body.filterIssue != '' ) {
|
|
372
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'Identified Issues' && req.body.filterIssue != 'Issues Not Identified'&&req.body.filterIssue != 'All Issues' ) {
|
|
347
373
|
query.push( {
|
|
348
374
|
$match: {
|
|
349
375
|
primaryIssue: req.body.filterIssue,
|
|
@@ -375,6 +401,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
375
401
|
} );
|
|
376
402
|
}
|
|
377
403
|
let count = await aggregateTangoTicket( query );
|
|
404
|
+
console.log( count.length );
|
|
378
405
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
379
406
|
query.push(
|
|
380
407
|
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
@@ -389,9 +416,9 @@ export async function infraIssuesTable( req, res ) {
|
|
|
389
416
|
'CREATED AT': element.createdAt,
|
|
390
417
|
'STORE ID': element.storeId,
|
|
391
418
|
'STORE NAME': element.storeName,
|
|
419
|
+
'PRIMARY ISSUE': element.primaryIssue,
|
|
392
420
|
'SUB ISSUE': element.secondaryIssue,
|
|
393
|
-
'ISSUE IDENTIFIED ON': element.issueIdentifiedDate,
|
|
394
|
-
'ISSUE CLOSED ON': element.issueClosedDate,
|
|
421
|
+
'ISSUE IDENTIFIED ON': dayjs( element.issueIdentifiedDate ).tz( 'Asia/Kolkata' ).format( 'YYYY-MM-DD HH:mm A' ),
|
|
395
422
|
'STATUS': element.status,
|
|
396
423
|
} );
|
|
397
424
|
} );
|
|
@@ -418,9 +445,10 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
418
445
|
$match: {
|
|
419
446
|
$and: [
|
|
420
447
|
{ issueType: 'installation' },
|
|
448
|
+
{ 'status': { $ne: 'closed' } },
|
|
421
449
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
422
|
-
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
423
|
-
|
|
450
|
+
// { createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
451
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
424
452
|
],
|
|
425
453
|
},
|
|
426
454
|
},
|
|
@@ -537,11 +565,15 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
537
565
|
export async function hourWiseDownClients( req, res ) {
|
|
538
566
|
try {
|
|
539
567
|
let inputData = req.body;
|
|
540
|
-
|
|
568
|
+
let clientList = await findClient( { clientId: { $in: req.body.clientId }, status: 'active' } );
|
|
569
|
+
let activeClient = [];
|
|
570
|
+
for ( let client of clientList ) {
|
|
571
|
+
activeClient.push( client.clientId );
|
|
572
|
+
}
|
|
541
573
|
let query = [
|
|
542
574
|
{
|
|
543
575
|
$match: {
|
|
544
|
-
clientId: { $in:
|
|
576
|
+
clientId: { $in: activeClient },
|
|
545
577
|
},
|
|
546
578
|
},
|
|
547
579
|
{
|
|
@@ -685,22 +717,63 @@ function generateTimeSlots( startHour, endHour, interval, time ) {
|
|
|
685
717
|
export async function hourWiseDownstores( req, res ) {
|
|
686
718
|
try {
|
|
687
719
|
let inputData = req.body;
|
|
688
|
-
inputData.Date = dayjs().format( 'YYYY-MM-DD' );
|
|
689
|
-
|
|
720
|
+
inputData.Date = dayjs( req.body.toDate ).format( 'YYYY-MM-DD' );
|
|
721
|
+
let issueStatus = [ 'identified' ];
|
|
722
|
+
if ( req.body.filterIssue == 'Issues Not Identified' ) {
|
|
723
|
+
issueStatus = [ 'notidentified' ];
|
|
724
|
+
};
|
|
725
|
+
if ( req.body.filterIssue == 'All Issues' ) {
|
|
726
|
+
issueStatus = [ 'notidentified', 'identified' ];
|
|
727
|
+
};
|
|
690
728
|
let query = [ {
|
|
691
729
|
$match: {
|
|
692
|
-
|
|
693
|
-
|
|
730
|
+
$and: [
|
|
731
|
+
{ 'basicDetails.clientId': req.body.clientId },
|
|
732
|
+
{ 'status': { $ne: 'closed' } },
|
|
733
|
+
{ issueType: 'infra' },
|
|
734
|
+
{ 'ticketDetails.issueStatus': { $in: issueStatus } },
|
|
735
|
+
{ 'issueDate': { $lte: new Date( req.body.toDate ) } },
|
|
736
|
+
],
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
$project: {
|
|
741
|
+
storeId: '$basicDetails.storeId',
|
|
742
|
+
storeName: '$basicDetails.storeName',
|
|
743
|
+
primaryIssue: {
|
|
744
|
+
$filter: {
|
|
745
|
+
input: '$ticketActivity',
|
|
746
|
+
as: 'item',
|
|
747
|
+
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
$unwind: {
|
|
754
|
+
path: '$primaryIssue', preserveNullAndEmptyArrays: true,
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
$unwind: {
|
|
759
|
+
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
694
760
|
},
|
|
695
761
|
},
|
|
696
762
|
{
|
|
697
763
|
$project: {
|
|
698
764
|
storeId: 1,
|
|
699
765
|
storeName: 1,
|
|
700
|
-
|
|
766
|
+
primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', 'NotIdentified' ] },
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
$group: {
|
|
771
|
+
_id: '$storeId',
|
|
772
|
+
storeId: { $first: '$storeId' },
|
|
773
|
+
storeName: { $first: '$storeName' },
|
|
774
|
+
primaryIssue: { $last: '$primaryIssue' },
|
|
701
775
|
},
|
|
702
776
|
},
|
|
703
|
-
|
|
704
777
|
];
|
|
705
778
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
706
779
|
query.push( {
|
|
@@ -717,14 +790,21 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
717
790
|
$sort: { [req.body.sortColumName]: req.body.sortBy },
|
|
718
791
|
} );
|
|
719
792
|
}
|
|
720
|
-
|
|
793
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' && req.body.filterIssue != 'Identified Issues' && req.body.filterIssue != 'Issues Not Identified'&&req.body.filterIssue != 'All Issues' ) {
|
|
794
|
+
query.push( {
|
|
795
|
+
$match: {
|
|
796
|
+
primaryIssue: req.body.filterIssue,
|
|
797
|
+
},
|
|
798
|
+
} );
|
|
799
|
+
}
|
|
800
|
+
let count = await aggregateTangoTicket( query );
|
|
721
801
|
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
722
802
|
query.push(
|
|
723
803
|
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
724
804
|
{ $limit: Number( req.body.limit ) },
|
|
725
805
|
);
|
|
726
806
|
}
|
|
727
|
-
let storeslist = await
|
|
807
|
+
let storeslist = await aggregateTangoTicket( query );
|
|
728
808
|
if ( storeslist.length == 0 ) {
|
|
729
809
|
return res.sendError( 'no data', 204 );
|
|
730
810
|
}
|
|
@@ -733,6 +813,7 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
733
813
|
for ( const store of storeslist ) {
|
|
734
814
|
data.storeId = store.storeId;
|
|
735
815
|
data.storeName = store.storeName;
|
|
816
|
+
data.primaryIssue = store.primaryIssue;
|
|
736
817
|
let storedata = await downStoresCheck( data, inputData );
|
|
737
818
|
result.push( storedata[0] );
|
|
738
819
|
}
|
|
@@ -801,7 +882,7 @@ function downStoresCheck( data, inputData ) {
|
|
|
801
882
|
const mergedData = {
|
|
802
883
|
storeName: data.storeName,
|
|
803
884
|
storeId: data.storeId,
|
|
804
|
-
|
|
885
|
+
PrimaryIssue: data.primaryIssue,
|
|
805
886
|
};
|
|
806
887
|
timewise.forEach( ( obj ) => {
|
|
807
888
|
for ( const key in obj ) {
|
|
@@ -5,7 +5,7 @@ export async function createTicket( req, res ) {
|
|
|
5
5
|
try {
|
|
6
6
|
let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
|
|
7
7
|
if ( ticketExist ) {
|
|
8
|
-
return res.
|
|
8
|
+
return res.status( 409 ).send( 'DataMismatch Ticket Already Exists for the store' );
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
req.body.issueDate = new Date( req.body.Date );
|