tango-app-api-infra 3.0.16 → 3.0.17
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 +4 -3
- package/src/controllers/clientInfra.controller.js +9 -0
- package/src/controllers/infra.controllers.js +1 -1
- package/src/controllers/storeInfra.controlller.js +41 -5
- package/src/controllers/userInfra.controller.js +170 -47
- package/src/routes/userInfra.routes.js +2 -1
- package/src/validations/infra.validation.js +1 -0
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.17",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"aws-sdk": "^2.1571.0",
|
|
17
|
+
"cors": "^2.8.5",
|
|
17
18
|
"dayjs": "^1.11.10",
|
|
18
19
|
"dotenv": "^16.4.5",
|
|
19
20
|
"express": "^4.18.3",
|
|
20
21
|
"handlebars": "^4.7.8",
|
|
21
22
|
"mongodb": "^6.4.0",
|
|
22
23
|
"nodemon": "^3.1.0",
|
|
23
|
-
"tango-api-schema": "^2.0.
|
|
24
|
-
"tango-app-api-middleware": "^1.0.
|
|
24
|
+
"tango-api-schema": "^2.0.49",
|
|
25
|
+
"tango-app-api-middleware": "^1.0.29",
|
|
25
26
|
"winston": "^3.12.0",
|
|
26
27
|
"winston-daily-rotate-file": "^5.0.0"
|
|
27
28
|
},
|
|
@@ -101,6 +101,7 @@ export async function infraCard( req, res ) {
|
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
let ticketList = await aggregateTangoTicket( query );
|
|
104
|
+
|
|
104
105
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
105
106
|
const categoryCounts = {};
|
|
106
107
|
let response;
|
|
@@ -494,6 +495,10 @@ export async function hourWiseDownClients( req, res ) {
|
|
|
494
495
|
let clientdata = await livecountCheck( data, inputData );
|
|
495
496
|
result.push( clientdata[0] );
|
|
496
497
|
}
|
|
498
|
+
if ( req.body.export && result.length > 0 ) {
|
|
499
|
+
await download( result, res );
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
497
502
|
res.sendSuccess( { count: count.length, result: result } );
|
|
498
503
|
} catch ( error ) {
|
|
499
504
|
logger.error( { error: error, function: 'hourWiseDownClients' } );
|
|
@@ -639,6 +644,10 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
639
644
|
let storedata = await downStoresCheck( data, inputData );
|
|
640
645
|
result.push( storedata[0] );
|
|
641
646
|
}
|
|
647
|
+
if ( req.body.export && result.length > 0 ) {
|
|
648
|
+
await download( result, res );
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
642
651
|
res.sendSuccess( { count: count.length, result: result } );
|
|
643
652
|
} catch ( error ) {
|
|
644
653
|
logger.error( { error: error, function: 'hourWiseDownstores' } );
|
|
@@ -108,7 +108,7 @@ export async function updateTicketIssue( req, res ) {
|
|
|
108
108
|
|
|
109
109
|
export async function viewTicket( req, res ) {
|
|
110
110
|
try {
|
|
111
|
-
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketActivity: 1 } );
|
|
111
|
+
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketDetails: 1, basicDetails: 1, ticketActivity: 1 } );
|
|
112
112
|
if ( ticket ) {
|
|
113
113
|
res.sendSuccess( ticket );
|
|
114
114
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { logger, getOpenSearchData } from 'tango-app-api-middleware';
|
|
2
|
+
import { logger, getOpenSearchData, download } from 'tango-app-api-middleware';
|
|
3
3
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { findOneStore } from '../services/store.service.js';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
@@ -8,14 +8,18 @@ export async function storeTicketList( req, res ) {
|
|
|
8
8
|
try {
|
|
9
9
|
let query = [ {
|
|
10
10
|
$match: {
|
|
11
|
-
|
|
11
|
+
$and: [
|
|
12
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
13
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
14
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
15
|
+
],
|
|
12
16
|
},
|
|
13
17
|
},
|
|
14
18
|
{
|
|
15
19
|
$project: {
|
|
16
20
|
storeId: '$basicDetails.storeId',
|
|
17
21
|
status: 1,
|
|
18
|
-
Date: { $dateToString: { format: '%d-%m-%Y', date: '$
|
|
22
|
+
Date: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
19
23
|
issueClosedDate: 1,
|
|
20
24
|
ticketId: 1,
|
|
21
25
|
issueStatus: '$ticketDetails.issueStatus',
|
|
@@ -53,7 +57,30 @@ export async function storeTicketList( req, res ) {
|
|
|
53
57
|
},
|
|
54
58
|
},
|
|
55
59
|
];
|
|
60
|
+
|
|
61
|
+
if ( req.body.filter && req.body.filter !== '' ) {
|
|
62
|
+
query.push( {
|
|
63
|
+
$match: {
|
|
64
|
+
primaryIssue: req.body.filter,
|
|
65
|
+
},
|
|
66
|
+
} );
|
|
67
|
+
}
|
|
56
68
|
let ticketList = await aggregateTangoTicket( query );
|
|
69
|
+
if ( req.body.export && ticketList.length > 0 ) {
|
|
70
|
+
const exportdata = [];
|
|
71
|
+
ticketList.forEach( ( element ) => {
|
|
72
|
+
exportdata.push( {
|
|
73
|
+
'STORE ID': element.storeId,
|
|
74
|
+
'TICKET ID': element.ticketId,
|
|
75
|
+
'DATE': element.Date,
|
|
76
|
+
'ISSUE CLOSED DATE': element.issueClosedDate,
|
|
77
|
+
'ISSUE': element.primaryIssue,
|
|
78
|
+
'STATUS': element.status,
|
|
79
|
+
} );
|
|
80
|
+
} );
|
|
81
|
+
await download( exportdata, res );
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
57
84
|
if ( ticketList.length ) {
|
|
58
85
|
res.sendSuccess( {
|
|
59
86
|
count: ticketList.length,
|
|
@@ -72,8 +99,13 @@ export async function storeTicketcard( req, res ) {
|
|
|
72
99
|
try {
|
|
73
100
|
let query = [ {
|
|
74
101
|
$match: {
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
$and: [
|
|
103
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
104
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
105
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
106
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
107
|
+
],
|
|
108
|
+
|
|
77
109
|
},
|
|
78
110
|
},
|
|
79
111
|
{
|
|
@@ -309,6 +341,10 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
309
341
|
const appStatus = await getOpenSearchData( 'edgeapp_systemlogs', appStatusQuery );
|
|
310
342
|
obj.appStatus = appStatus.body.hits.hits.length > 0 ? appStatus.body.hits.hits[0]._source.data.message : '';
|
|
311
343
|
}
|
|
344
|
+
if ( req.body.export ) {
|
|
345
|
+
await download( timeSlots, res );
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
312
348
|
res.sendSuccess( timeSlots );
|
|
313
349
|
} catch ( error ) {
|
|
314
350
|
logger.error( { error: error, function: 'edgeAppLog' } );
|
|
@@ -94,7 +94,41 @@ export async function userTicketList( req, res ) {
|
|
|
94
94
|
infraIssue: '$primaryIssue.reasons.primaryIssue',
|
|
95
95
|
},
|
|
96
96
|
} );
|
|
97
|
+
|
|
98
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
99
|
+
query.push( {
|
|
100
|
+
$match: {
|
|
101
|
+
$or: [
|
|
102
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
103
|
+
{ infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
} );
|
|
107
|
+
}
|
|
108
|
+
if ( req.body.filter && req.body.filter !== '' ) {
|
|
109
|
+
query.push( {
|
|
110
|
+
$match: {
|
|
111
|
+
$or: [
|
|
112
|
+
{ issueStatus: req.body.filter },
|
|
113
|
+
{ infraIssue: req.body.filter },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
} );
|
|
117
|
+
}
|
|
97
118
|
let ticketList = await aggregateTangoTicket( query );
|
|
119
|
+
if ( req.body.export ) {
|
|
120
|
+
const exportdata = [];
|
|
121
|
+
ticketList.forEach( ( element ) => {
|
|
122
|
+
exportdata.push( {
|
|
123
|
+
'DATE': element.Date,
|
|
124
|
+
'TICKET ID': element.ticketId,
|
|
125
|
+
'STORE ID': element.storeId,
|
|
126
|
+
'ISSUE': element.issueStatus,
|
|
127
|
+
} );
|
|
128
|
+
} );
|
|
129
|
+
await download( exportdata, res );
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
98
132
|
if ( ticketList.length ) {
|
|
99
133
|
res.sendSuccess( {
|
|
100
134
|
count: ticketList.length,
|
|
@@ -108,6 +142,40 @@ export async function userTicketList( req, res ) {
|
|
|
108
142
|
return res.sendError( error, 500 );
|
|
109
143
|
}
|
|
110
144
|
}
|
|
145
|
+
export async function activeTicketList( req, res ) {
|
|
146
|
+
try {
|
|
147
|
+
let query = [ {
|
|
148
|
+
$match: {
|
|
149
|
+
$and: [
|
|
150
|
+
{ 'status': { $in: [ 'open', 'inprogress' ] } },
|
|
151
|
+
{ issueType: req.body.issueType },
|
|
152
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
}, {
|
|
156
|
+
$project: {
|
|
157
|
+
storeId: '$basicDetails.storeId',
|
|
158
|
+
address: { $ifNull: [ '$basicDetails.address', '' ] },
|
|
159
|
+
status: 1,
|
|
160
|
+
},
|
|
161
|
+
} ];
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
let ticketList = await aggregateTangoTicket( query );
|
|
165
|
+
|
|
166
|
+
if ( ticketList.length ) {
|
|
167
|
+
res.sendSuccess( {
|
|
168
|
+
count: ticketList.length,
|
|
169
|
+
data: ticketList,
|
|
170
|
+
} );
|
|
171
|
+
} else {
|
|
172
|
+
return res.sendError( 'NO data', 204 );
|
|
173
|
+
}
|
|
174
|
+
} catch ( error ) {
|
|
175
|
+
logger.error( { error: error, function: 'activeTicketList' } );
|
|
176
|
+
return res.sendError( error, 500 );
|
|
177
|
+
}
|
|
178
|
+
}
|
|
111
179
|
export async function basicDetails( req, res ) {
|
|
112
180
|
try {
|
|
113
181
|
let user = await findOneUser( { _id: new mongoose.Types.ObjectId( req.body.userId ) }, { userName: 1, userType: 1 } );
|
|
@@ -141,56 +209,111 @@ export async function workHistory( req, res ) {
|
|
|
141
209
|
{ 'status': 'closed' },
|
|
142
210
|
{ issueType: req.body.issueType },
|
|
143
211
|
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
144
|
-
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
145
|
-
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
146
212
|
],
|
|
147
213
|
},
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
214
|
+
} ];
|
|
215
|
+
|
|
216
|
+
if ( req.body.dateFilter&&req.body.dateFilter !='' ) {
|
|
217
|
+
if ( req.body.dateFilter === 'issueIdentifiedDate' ) {
|
|
218
|
+
query.push(
|
|
219
|
+
{
|
|
220
|
+
$match: {
|
|
221
|
+
$and: [
|
|
222
|
+
{ 'ticketDetails.issueIdentifiedDate': { $gte: new Date( req.body.fromDate ) } },
|
|
223
|
+
{ 'ticketDetails.issueIdentifiedDate': { $lte: new Date( req.body.toDate ) } },
|
|
224
|
+
],
|
|
225
|
+
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
} else if ( req.body.dateFilter === 'closedDate' ) {
|
|
230
|
+
query.push(
|
|
231
|
+
{
|
|
232
|
+
$match: {
|
|
233
|
+
$and: [
|
|
234
|
+
{ 'issueClosedDate': { $gte: new Date( req.body.fromDate ) } },
|
|
235
|
+
{ 'issueClosedDate': { $lte: new Date( req.body.toDate ) } },
|
|
236
|
+
],
|
|
237
|
+
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
);
|
|
241
|
+
} else {
|
|
242
|
+
query.push(
|
|
243
|
+
{
|
|
244
|
+
$match: {
|
|
245
|
+
$and: [
|
|
246
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
247
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
248
|
+
],
|
|
249
|
+
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if ( req.body.storeFilter&&req.body.storeFilter.length>0 ) {
|
|
257
|
+
query.push(
|
|
258
|
+
{
|
|
259
|
+
$match: {
|
|
260
|
+
'basicDetails.storeId': { $in: req.body.storeFilter } },
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
query.push(
|
|
265
|
+
{
|
|
266
|
+
$project: {
|
|
267
|
+
storeId: '$basicDetails.storeId',
|
|
268
|
+
storeName: '$basicDetails.storeName',
|
|
269
|
+
clientId: '$basicDetails.clientId',
|
|
270
|
+
clientName: '$basicDetails.clientName',
|
|
271
|
+
issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
272
|
+
issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
|
|
273
|
+
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
274
|
+
ticketId: 1,
|
|
275
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
276
|
+
ticketType: '$ticketDetails.ticketType',
|
|
277
|
+
primaryIssue: {
|
|
278
|
+
$filter: {
|
|
279
|
+
input: '$ticketActivity',
|
|
280
|
+
as: 'item',
|
|
281
|
+
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
282
|
+
},
|
|
283
|
+
},
|
|
166
284
|
},
|
|
167
285
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
286
|
+
{
|
|
287
|
+
$unwind: {
|
|
288
|
+
path: '$primaryIssue', preserveNullAndEmptyArrays: true,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
$unwind: {
|
|
293
|
+
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
294
|
+
},
|
|
295
|
+
}, {
|
|
296
|
+
$project: {
|
|
297
|
+
storeId: 1,
|
|
298
|
+
storeName: 1,
|
|
299
|
+
clientId: 1,
|
|
300
|
+
clientName: 1,
|
|
301
|
+
issueDate: 1,
|
|
302
|
+
issueIdentifiedDate: 1,
|
|
303
|
+
issueClosedDate: 1,
|
|
304
|
+
ticketId: 1,
|
|
305
|
+
issueStatus: 1,
|
|
306
|
+
ticketType: 1,
|
|
307
|
+
infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
|
|
308
|
+
},
|
|
309
|
+
} );
|
|
310
|
+
if ( req.body.issueFilter && req.body.issueFilter !== '' ) {
|
|
311
|
+
query.push( {
|
|
312
|
+
$match: {
|
|
313
|
+
infraIssue: req.body.issueFilter,
|
|
314
|
+
},
|
|
315
|
+
} );
|
|
316
|
+
}
|
|
194
317
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
195
318
|
query.push( {
|
|
196
319
|
$match: {
|
|
@@ -290,7 +413,7 @@ export async function storeInfraList( req, res ) {
|
|
|
290
413
|
},
|
|
291
414
|
},
|
|
292
415
|
];
|
|
293
|
-
if ( req.body.storeId && req.body.storeId.length>0 ) {
|
|
416
|
+
if ( req.body.storeId && req.body.storeId.length > 0 ) {
|
|
294
417
|
query.push( {
|
|
295
418
|
$match: {
|
|
296
419
|
storeId: { $in: req.body.storeId },
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
|
-
import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
3
|
+
import { userTakeTicket, userTicketList, activeTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
4
4
|
|
|
5
5
|
export const userInfraRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
userInfraRouter.post( '/userTakeTicket', isAllowedSessionHandler, userTakeTicket );
|
|
9
9
|
userInfraRouter.post( '/userTicketList', isAllowedSessionHandler, userTicketList );
|
|
10
|
+
userInfraRouter.post( '/activeTicketList', isAllowedSessionHandler, activeTicketList );
|
|
10
11
|
userInfraRouter.post( '/basicDetails', isAllowedSessionHandler, basicDetails );
|
|
11
12
|
userInfraRouter.post( '/workHistory', isAllowedSessionHandler, workHistory );
|
|
12
13
|
userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, storeInfraList );
|
|
@@ -18,6 +18,7 @@ export async function validateDetails( req, res, next ) {
|
|
|
18
18
|
req.body.basicDetails = {
|
|
19
19
|
storeId: req.body.storeId,
|
|
20
20
|
storeName: store.storeName,
|
|
21
|
+
address: store.storeProfile&&store.storeProfile.address?store.storeProfile.address:'',
|
|
21
22
|
clientId: store.clientId,
|
|
22
23
|
clientName: client.clientName,
|
|
23
24
|
};
|