tango-app-api-infra 3.0.14 → 3.0.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 +2 -2
- package/src/controllers/clientInfra.controller.js +121 -12
- package/src/controllers/infra.controllers.js +10 -7
- package/src/controllers/internalInfra.controller.js +5 -5
- package/src/controllers/storeInfra.controlller.js +6 -6
- package/src/controllers/userInfra.controller.js +26 -14
- package/src/routes/clientInfra.routes.js +2 -1
- package/src/validations/infra.validation.js +26 -8
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.15",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"handlebars": "^4.7.8",
|
|
21
21
|
"mongodb": "^6.4.0",
|
|
22
22
|
"nodemon": "^3.1.0",
|
|
23
|
-
"tango-api-schema": "^2.0.
|
|
23
|
+
"tango-api-schema": "^2.0.44",
|
|
24
24
|
"tango-app-api-middleware": "^1.0.21",
|
|
25
25
|
"winston": "^3.12.0",
|
|
26
26
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { countDocumentsStore, findStorewithpagination } from '../services/store.service.js';
|
|
3
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
|
+
import { logger, download } from 'tango-app-api-middleware';
|
|
4
4
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
5
5
|
import { findinfraReason } from '../services/infraReason.service.js';
|
|
6
6
|
import { findClientwithpagination } from '../services/client.service.js';
|
|
@@ -26,7 +26,7 @@ export async function infraCard( req, res ) {
|
|
|
26
26
|
$project: {
|
|
27
27
|
storeId: '$basicDetails.storeId',
|
|
28
28
|
identifiedcount: {
|
|
29
|
-
$cond: [ { $eq: [ '$
|
|
29
|
+
$cond: [ { $eq: [ '$ticketDetails.issueStatus', 'identified' ] }, 1, 0 ],
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -51,7 +51,7 @@ export async function infraCard( req, res ) {
|
|
|
51
51
|
{ issueType: 'infra' },
|
|
52
52
|
{ 'status': { $ne: 'closed' } },
|
|
53
53
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
54
|
-
{ '
|
|
54
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
55
55
|
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
56
56
|
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
57
57
|
],
|
|
@@ -60,10 +60,11 @@ export async function infraCard( req, res ) {
|
|
|
60
60
|
{
|
|
61
61
|
$project: {
|
|
62
62
|
ticketId: 1,
|
|
63
|
-
issueStatus: '$
|
|
63
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
64
|
+
issueIdentifiedBy: '$ticketDetails.issueIdentifiedBy',
|
|
64
65
|
primaryIssue: {
|
|
65
66
|
$filter: {
|
|
66
|
-
input: '$
|
|
67
|
+
input: '$ticketActivity',
|
|
67
68
|
as: 'item',
|
|
68
69
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
69
70
|
},
|
|
@@ -85,10 +86,20 @@ export async function infraCard( req, res ) {
|
|
|
85
86
|
ticketId: 1,
|
|
86
87
|
issueStatus: 1,
|
|
87
88
|
ticketType: 1,
|
|
89
|
+
issueIdentifiedBy: 1,
|
|
88
90
|
primaryIssue: '$primaryIssue.reasons.primaryIssue',
|
|
89
91
|
},
|
|
90
92
|
},
|
|
91
93
|
];
|
|
94
|
+
if ( req.body.filter&&req.body.filter.length>0 ) {
|
|
95
|
+
query.push(
|
|
96
|
+
{
|
|
97
|
+
$match: {
|
|
98
|
+
issueIdentifiedBy: { $in: req.body.filter },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}
|
|
92
103
|
let ticketList = await aggregateTangoTicket( query );
|
|
93
104
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
94
105
|
const categoryCounts = {};
|
|
@@ -125,7 +136,104 @@ export async function infraCard( req, res ) {
|
|
|
125
136
|
return res.sendError( error, 500 );
|
|
126
137
|
}
|
|
127
138
|
}
|
|
139
|
+
export async function installationCard( req, res ) {
|
|
140
|
+
try {
|
|
141
|
+
let onboardedCount = await countDocumentsStore( { clientId: { $in: req.body.clientId } } );
|
|
142
|
+
let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.deployed': true } );
|
|
128
143
|
|
|
144
|
+
let yettoInstallCount = await aggregateTangoTicket( [
|
|
145
|
+
{
|
|
146
|
+
$match: {
|
|
147
|
+
$and: [
|
|
148
|
+
{ issueType: 'installation' },
|
|
149
|
+
{ 'status': { $ne: 'closed' } },
|
|
150
|
+
{ 'ticketDetails.issueStatus': 'notidentified' },
|
|
151
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
152
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
] );
|
|
157
|
+
let query = [ {
|
|
158
|
+
$match: {
|
|
159
|
+
$and: [
|
|
160
|
+
{ issueType: 'installation' },
|
|
161
|
+
{ 'status': { $ne: 'closed' } },
|
|
162
|
+
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
163
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
164
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
$project: {
|
|
170
|
+
ticketId: 1,
|
|
171
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
172
|
+
issueIdentifiedBy: '$ticketDetails.issueIdentifiedBy',
|
|
173
|
+
primaryIssue: {
|
|
174
|
+
$filter: {
|
|
175
|
+
input: '$ticketActivity',
|
|
176
|
+
as: 'item',
|
|
177
|
+
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
$unwind: {
|
|
184
|
+
path: '$primaryIssue', preserveNullAndEmptyArrays: true,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
$unwind: {
|
|
189
|
+
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
$project: {
|
|
194
|
+
ticketId: 1,
|
|
195
|
+
issueStatus: 1,
|
|
196
|
+
ticketType: 1,
|
|
197
|
+
issueIdentifiedBy: 1,
|
|
198
|
+
primaryIssue: '$primaryIssue.reasons.primaryIssue',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
let installFailedCount = await aggregateTangoTicket( query );
|
|
203
|
+
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
204
|
+
const categoryCounts = {};
|
|
205
|
+
let response;
|
|
206
|
+
if ( installFailedCount.length > 0 ) {
|
|
207
|
+
installFailedCount.forEach( ( item ) => {
|
|
208
|
+
const categoryName = item.primaryIssue;
|
|
209
|
+
if ( categoryCounts[categoryName] ) {
|
|
210
|
+
categoryCounts[categoryName]++;
|
|
211
|
+
} else {
|
|
212
|
+
categoryCounts[categoryName] = 1;
|
|
213
|
+
}
|
|
214
|
+
} );
|
|
215
|
+
response = issueList.map( ( category ) => ( {
|
|
216
|
+
name: category.name,
|
|
217
|
+
count: categoryCounts[category.name] || 0,
|
|
218
|
+
} ) );
|
|
219
|
+
} else {
|
|
220
|
+
response = issueList.map( ( category ) => ( {
|
|
221
|
+
name: category.name,
|
|
222
|
+
count: 0,
|
|
223
|
+
} ) );
|
|
224
|
+
}
|
|
225
|
+
res.sendSuccess( {
|
|
226
|
+
onboardedStoresCount: onboardedCount,
|
|
227
|
+
installedStoresCount: installedCount,
|
|
228
|
+
yettoInstallCount: yettoInstallCount.length,
|
|
229
|
+
installFailedCount: installFailedCount.length,
|
|
230
|
+
infraIssues: response,
|
|
231
|
+
} );
|
|
232
|
+
} catch ( error ) {
|
|
233
|
+
logger.error( { error: error, function: 'infraCard' } );
|
|
234
|
+
return res.sendError( error, 500 );
|
|
235
|
+
}
|
|
236
|
+
}
|
|
129
237
|
export async function infraIssuesTable( req, res ) {
|
|
130
238
|
try {
|
|
131
239
|
let query = [ {
|
|
@@ -134,7 +242,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
134
242
|
{ issueType: 'infra' },
|
|
135
243
|
{ status: { $ne: 'closed' } },
|
|
136
244
|
{ 'basicDetails.clientId': { $in: req.body.clientId } },
|
|
137
|
-
{ '
|
|
245
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
138
246
|
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
139
247
|
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
140
248
|
],
|
|
@@ -146,11 +254,11 @@ export async function infraIssuesTable( req, res ) {
|
|
|
146
254
|
storeName: '$basicDetails.storeName',
|
|
147
255
|
status: 1,
|
|
148
256
|
createdAt: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
149
|
-
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$
|
|
257
|
+
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
150
258
|
issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
|
|
151
259
|
primaryIssue: {
|
|
152
260
|
$filter: {
|
|
153
|
-
input: '$
|
|
261
|
+
input: '$ticketActivity',
|
|
154
262
|
as: 'item',
|
|
155
263
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
156
264
|
},
|
|
@@ -187,6 +295,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
187
295
|
{
|
|
188
296
|
$group: {
|
|
189
297
|
_id: '$storeId',
|
|
298
|
+
storeId: { $first: '$storeId' },
|
|
190
299
|
storeName: { $first: '$storeName' },
|
|
191
300
|
createdAt: { $first: '$createdAt' },
|
|
192
301
|
issueIdentifiedDate: { $first: '$issueIdentifiedDate' },
|
|
@@ -197,14 +306,14 @@ export async function infraIssuesTable( req, res ) {
|
|
|
197
306
|
},
|
|
198
307
|
},
|
|
199
308
|
];
|
|
200
|
-
if ( req.body.filterIssue && req.body.filterIssue
|
|
309
|
+
if ( req.body.filterIssue && req.body.filterIssue != '' ) {
|
|
201
310
|
query.push( {
|
|
202
311
|
$match: {
|
|
203
312
|
primaryIssue: req.body.filterIssue,
|
|
204
313
|
},
|
|
205
314
|
} );
|
|
206
315
|
}
|
|
207
|
-
if ( req.body.searchValue && req.body.searchValue
|
|
316
|
+
if ( req.body.searchValue && req.body.searchValue != '' ) {
|
|
208
317
|
query.push( {
|
|
209
318
|
$match: {
|
|
210
319
|
$or: [
|
|
@@ -278,7 +387,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
278
387
|
clientName: '$basicDetails.clientName',
|
|
279
388
|
storeId: '$basicDetails.storeId',
|
|
280
389
|
storeName: '$basicDetails.storeName',
|
|
281
|
-
status:
|
|
390
|
+
status: 1,
|
|
282
391
|
},
|
|
283
392
|
},
|
|
284
393
|
];
|
|
@@ -399,7 +508,7 @@ export async function livecountCheck( data, inputData ) {
|
|
|
399
508
|
timewise.push( obj );
|
|
400
509
|
}
|
|
401
510
|
const mergedData = {
|
|
402
|
-
|
|
511
|
+
clientName: data.clientName,
|
|
403
512
|
};
|
|
404
513
|
timewise.forEach( ( obj ) => {
|
|
405
514
|
for ( const key in obj ) {
|
|
@@ -6,14 +6,17 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
6
6
|
export async function createTicket( req, res ) {
|
|
7
7
|
try {
|
|
8
8
|
req.body.issueDate = new Date( req.body.Date );
|
|
9
|
-
req.body.
|
|
9
|
+
req.body.ticketDetails.filesCount = req.body.filesCount;
|
|
10
10
|
if ( req.body.issueType == 'infra' ) {
|
|
11
11
|
req.body.ticketId = 'TE_INF_' + new Date().valueOf();
|
|
12
|
-
req.body.
|
|
12
|
+
req.body.ticketActivity = [ {
|
|
13
13
|
actionType: 'defaultInfra',
|
|
14
14
|
actionBy: 'Tango',
|
|
15
15
|
} ];
|
|
16
16
|
}
|
|
17
|
+
if ( req.body.issueType == 'installation' ) {
|
|
18
|
+
req.body.ticketId = 'TE_INS_' + new Date().valueOf();
|
|
19
|
+
}
|
|
17
20
|
let create = await createTangoTicket( req.body );
|
|
18
21
|
if ( create ) {
|
|
19
22
|
res.sendSuccess( 'Ticket Created Successfully' );
|
|
@@ -27,7 +30,7 @@ export async function createTicket( req, res ) {
|
|
|
27
30
|
export async function updateStatus( req, res ) {
|
|
28
31
|
try {
|
|
29
32
|
if ( req.body.status == 'inprogress' ) {
|
|
30
|
-
req.body.
|
|
33
|
+
req.body.ticketActivity.push( {
|
|
31
34
|
actionType: 'statusChange',
|
|
32
35
|
actionBy: 'User',
|
|
33
36
|
} );
|
|
@@ -91,7 +94,7 @@ export async function secondaryReason( req, res ) {
|
|
|
91
94
|
|
|
92
95
|
export async function updateTicketIssue( req, res ) {
|
|
93
96
|
try {
|
|
94
|
-
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
97
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified' } );
|
|
95
98
|
if ( updateTicket ) {
|
|
96
99
|
res.sendSuccess( 'Ticket Updated Successfully' );
|
|
97
100
|
}
|
|
@@ -103,7 +106,7 @@ export async function updateTicketIssue( req, res ) {
|
|
|
103
106
|
|
|
104
107
|
export async function viewTicket( req, res ) {
|
|
105
108
|
try {
|
|
106
|
-
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1,
|
|
109
|
+
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketActivity: 1 } );
|
|
107
110
|
if ( ticket ) {
|
|
108
111
|
res.sendSuccess( ticket );
|
|
109
112
|
}
|
|
@@ -114,8 +117,8 @@ export async function viewTicket( req, res ) {
|
|
|
114
117
|
}
|
|
115
118
|
export async function AlertTicketReply( req, res ) {
|
|
116
119
|
try {
|
|
117
|
-
req.body.
|
|
118
|
-
req.body.
|
|
120
|
+
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.action !='statusCheck' );
|
|
121
|
+
req.body.ticketActivity.push( {
|
|
119
122
|
actionType: 'statusCheckReply',
|
|
120
123
|
actionBy: 'Tango',
|
|
121
124
|
statusCheckReply: req.body.statusCheckReply,
|
|
@@ -112,7 +112,7 @@ export async function downStoresList( req, res ) {
|
|
|
112
112
|
}
|
|
113
113
|
export async function openTicketList( req, res ) {
|
|
114
114
|
try {
|
|
115
|
-
let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1,
|
|
115
|
+
let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, ticketDetails: 1 } );
|
|
116
116
|
if ( openTicketList.length ) {
|
|
117
117
|
res.sendSuccess( {
|
|
118
118
|
count: openTicketList.length,
|
|
@@ -129,7 +129,7 @@ export async function openTicketList( req, res ) {
|
|
|
129
129
|
|
|
130
130
|
export async function assigntoUser( req, res ) {
|
|
131
131
|
try {
|
|
132
|
-
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
132
|
+
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.assigntoUser': true } );
|
|
133
133
|
res.sendSuccess( 'assigntoUser Successfully' );
|
|
134
134
|
} catch ( error ) {
|
|
135
135
|
logger.error( { error: error, function: 'assigntoUser' } );
|
|
@@ -138,7 +138,7 @@ export async function assigntoUser( req, res ) {
|
|
|
138
138
|
}
|
|
139
139
|
export async function updateRefreshTicket( req, res ) {
|
|
140
140
|
try {
|
|
141
|
-
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { '
|
|
141
|
+
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
|
|
142
142
|
res.sendSuccess( 'updated Successfully' );
|
|
143
143
|
} catch ( error ) {
|
|
144
144
|
logger.error( { error: error, function: 'updateRefreshTicket' } );
|
|
@@ -150,7 +150,7 @@ export async function closeTicket( req, res ) {
|
|
|
150
150
|
for ( let ticket of req.body.TicketList ) {
|
|
151
151
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
152
152
|
if ( ticket.status == 'closed' ) {
|
|
153
|
-
getTicket.
|
|
153
|
+
getTicket.ticketActivity.push( {
|
|
154
154
|
actionType: 'dataRecived',
|
|
155
155
|
actionBy: 'Tango',
|
|
156
156
|
} );
|
|
@@ -158,7 +158,7 @@ export async function closeTicket( req, res ) {
|
|
|
158
158
|
await updateOneTangoTicket( { ticketId: ticket.ticketId },
|
|
159
159
|
{
|
|
160
160
|
status: ticket.status,
|
|
161
|
-
|
|
161
|
+
ticketActivity: getTicket.ticketActivity,
|
|
162
162
|
issueClosedDate: new Date(),
|
|
163
163
|
},
|
|
164
164
|
);
|
|
@@ -18,11 +18,11 @@ export async function storeTicketList( req, res ) {
|
|
|
18
18
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
19
19
|
issueClosedDate: 1,
|
|
20
20
|
ticketId: 1,
|
|
21
|
-
issueStatus: '$
|
|
22
|
-
ticketType: '$
|
|
21
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
22
|
+
ticketType: '$ticketDetails.ticketType',
|
|
23
23
|
primaryIssue: {
|
|
24
24
|
$filter: {
|
|
25
|
-
input: '$
|
|
25
|
+
input: '$ticketActivity',
|
|
26
26
|
as: 'item',
|
|
27
27
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
28
28
|
},
|
|
@@ -73,16 +73,16 @@ export async function storeTicketcard( req, res ) {
|
|
|
73
73
|
let query = [ {
|
|
74
74
|
$match: {
|
|
75
75
|
'basicDetails.storeId': req.body.storeId,
|
|
76
|
-
'
|
|
76
|
+
'ticketDetails.issueStatus': 'identified',
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
$project: {
|
|
81
81
|
ticketId: 1,
|
|
82
|
-
issueStatus: '$
|
|
82
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
83
83
|
primaryIssue: {
|
|
84
84
|
$filter: {
|
|
85
|
-
input: '$
|
|
85
|
+
input: '$ticketActivity',
|
|
86
86
|
as: 'item',
|
|
87
87
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
88
88
|
},
|
|
@@ -8,9 +8,14 @@ import mongoose from 'mongoose';
|
|
|
8
8
|
|
|
9
9
|
export async function userTakeTicket( req, res ) {
|
|
10
10
|
try {
|
|
11
|
-
let userTicket =
|
|
11
|
+
let userTicket = '';
|
|
12
|
+
if ( req.body.issueType == 'infra' ) {
|
|
13
|
+
userTicket = await findOneTangoTicket( { 'status': { $ne: 'closed' }, 'issueType': 'infra', 'ticketDetails.assigntoUser': true, 'ticketDetails.addressingUser': { $exists: false } } );
|
|
14
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
15
|
+
userTicket = await findOneTangoTicket( { 'status': { $ne: 'closed' }, 'issueType': 'installation', 'ticketDetails.addressingUser': { $exists: false } } );
|
|
16
|
+
}
|
|
12
17
|
if ( userTicket ) {
|
|
13
|
-
let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { '
|
|
18
|
+
let assignTicket = await updateOneTangoTicket( { ticketId: userTicket.ticketId }, { 'ticketDetails.addressingUser': req.body.userId } );
|
|
14
19
|
if ( assignTicket ) {
|
|
15
20
|
res.sendSuccess( 'Ticket Assigned Successfully' );
|
|
16
21
|
}
|
|
@@ -28,7 +33,8 @@ export async function userTicketList( req, res ) {
|
|
|
28
33
|
$match: {
|
|
29
34
|
$and: [
|
|
30
35
|
{ 'status': req.body.status },
|
|
31
|
-
{
|
|
36
|
+
{ issueType: req.body.issueType },
|
|
37
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
32
38
|
],
|
|
33
39
|
},
|
|
34
40
|
} ];
|
|
@@ -58,11 +64,11 @@ export async function userTicketList( req, res ) {
|
|
|
58
64
|
storeId: '$basicDetails.storeId',
|
|
59
65
|
Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
60
66
|
ticketId: 1,
|
|
61
|
-
issueStatus: '$
|
|
62
|
-
ticketType: '$
|
|
67
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
68
|
+
ticketType: '$ticketDetails.ticketType',
|
|
63
69
|
primaryIssue: {
|
|
64
70
|
$filter: {
|
|
65
|
-
input: '$
|
|
71
|
+
input: '$ticketActivity',
|
|
66
72
|
as: 'item',
|
|
67
73
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
68
74
|
},
|
|
@@ -109,8 +115,8 @@ export async function basicDetails( req, res ) {
|
|
|
109
115
|
if ( !user ) {
|
|
110
116
|
return res.sendError( 'User Not Found', 500 );
|
|
111
117
|
}
|
|
112
|
-
let infraCount = await countDocumentsTangoTicket( { '
|
|
113
|
-
let installationCount = await countDocumentsTangoTicket( { '
|
|
118
|
+
let infraCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'infra' } );
|
|
119
|
+
let installationCount = await countDocumentsTangoTicket( { 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ), 'issueType': 'installation' } );
|
|
114
120
|
res.sendSuccess( {
|
|
115
121
|
userName: user.userName,
|
|
116
122
|
userType: user.userType,
|
|
@@ -133,7 +139,7 @@ export async function workHistory( req, res ) {
|
|
|
133
139
|
$match: {
|
|
134
140
|
$and: [
|
|
135
141
|
{ 'status': 'closed' },
|
|
136
|
-
{ '
|
|
142
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
137
143
|
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
138
144
|
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
139
145
|
],
|
|
@@ -147,13 +153,13 @@ export async function workHistory( req, res ) {
|
|
|
147
153
|
clientName: '$basicDetails.clientName',
|
|
148
154
|
issueDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
|
|
149
155
|
issueClosedDate: { $dateToString: { format: '%d-%m-%Y', date: '$issueClosedDate' } },
|
|
150
|
-
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$
|
|
156
|
+
issueIdentifiedDate: { $dateToString: { format: '%d-%m-%Y', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
151
157
|
ticketId: 1,
|
|
152
|
-
issueStatus: '$
|
|
153
|
-
ticketType: '$
|
|
158
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
159
|
+
ticketType: '$ticketDetails.ticketType',
|
|
154
160
|
primaryIssue: {
|
|
155
161
|
$filter: {
|
|
156
|
-
input: '$
|
|
162
|
+
input: '$ticketActivity',
|
|
157
163
|
as: 'item',
|
|
158
164
|
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
159
165
|
},
|
|
@@ -283,7 +289,13 @@ export async function storeInfraList( req, res ) {
|
|
|
283
289
|
},
|
|
284
290
|
},
|
|
285
291
|
];
|
|
286
|
-
|
|
292
|
+
if ( req.body.storeId && req.body.storeId.length>0 ) {
|
|
293
|
+
query.push( {
|
|
294
|
+
$match: {
|
|
295
|
+
storeId: { $in: req.body.storeId },
|
|
296
|
+
},
|
|
297
|
+
} );
|
|
298
|
+
}
|
|
287
299
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
288
300
|
query.push( {
|
|
289
301
|
$match: {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
4
|
-
import { infraCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
|
|
4
|
+
import { infraCard, installationCard, InstallationIssuesTable, infraIssuesTable, hourWiseDownClients, hourWiseDownstores } from '../controllers/clientInfra.controller.js';
|
|
5
5
|
|
|
6
6
|
export const clientInfraRouter = express.Router();
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
clientInfraRouter.post( '/infraCard', isAllowedSessionHandler, infraCard );
|
|
10
10
|
clientInfraRouter.post( '/infraIssuesTable', isAllowedSessionHandler, infraIssuesTable );
|
|
11
|
+
clientInfraRouter.post( '/installationCard', isAllowedSessionHandler, installationCard );
|
|
11
12
|
clientInfraRouter.post( '/InstallationIssuesTable', isAllowedSessionHandler, InstallationIssuesTable );
|
|
12
13
|
clientInfraRouter.post( '/hourWiseDownClients', isAllowedSessionHandler, hourWiseDownClients );
|
|
13
14
|
clientInfraRouter.post( '/hourWiseDownstores', isAllowedSessionHandler, hourWiseDownstores );
|
|
@@ -21,9 +21,16 @@ export async function validateDetails( req, res, next ) {
|
|
|
21
21
|
clientId: store.clientId,
|
|
22
22
|
clientName: client.clientName,
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
if ( req.body.issueType == 'infra' ) {
|
|
26
|
+
req.body.ticketDetails = {
|
|
27
|
+
ticketRefreshTime: dayjs().add( client.ticketConfigs.refreshAlert, 'days' ),
|
|
28
|
+
};
|
|
29
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
30
|
+
req.body.ticketDetails = {
|
|
31
|
+
ticketRefreshTime: dayjs().add( client.ticketConfigs.installationReAssign, 'days' ),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
next();
|
|
29
36
|
} catch ( error ) {
|
|
@@ -38,12 +45,23 @@ export async function validateTicket( req, res, next ) {
|
|
|
38
45
|
let Ticket = await findOneTangoTicket(
|
|
39
46
|
{
|
|
40
47
|
'basicDetails.storeId': req.body.basicDetails.storeId,
|
|
48
|
+
'issueType': 'infra',
|
|
41
49
|
'issueDate': new Date( req.body.Date ),
|
|
42
50
|
},
|
|
43
51
|
);
|
|
44
52
|
if ( Ticket ) {
|
|
45
53
|
return res.sendSuccess( 'Ticket Already Exists for the day' );
|
|
46
54
|
}
|
|
55
|
+
} else if ( req.body.issueType == 'installation' ) {
|
|
56
|
+
let Ticket = await findOneTangoTicket(
|
|
57
|
+
{
|
|
58
|
+
'basicDetails.storeId': req.body.basicDetails.storeId,
|
|
59
|
+
'issueType': req.body.issueType,
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
if ( Ticket ) {
|
|
63
|
+
return res.sendSuccess( 'Ticket Already Exists' );
|
|
64
|
+
}
|
|
47
65
|
}
|
|
48
66
|
next();
|
|
49
67
|
} catch ( error ) {
|
|
@@ -62,7 +80,7 @@ export async function ticketExists( req, res, next ) {
|
|
|
62
80
|
return res.sendError( 'Ticket Not Found', 204 );
|
|
63
81
|
}
|
|
64
82
|
req.body.basicDetails = Ticket.basicDetails;
|
|
65
|
-
req.body.
|
|
83
|
+
req.body.ticketActivity = Ticket.ticketActivity;
|
|
66
84
|
next();
|
|
67
85
|
} catch ( error ) {
|
|
68
86
|
logger.error( { error: error, function: 'ticketExists' } );
|
|
@@ -97,7 +115,7 @@ export async function infraReasonExists( req, res, next ) {
|
|
|
97
115
|
secondaryIsssue: [ ...resolveSteps ],
|
|
98
116
|
} );
|
|
99
117
|
}
|
|
100
|
-
req.body.
|
|
118
|
+
req.body.ticketActivity.push( {
|
|
101
119
|
actionType: 'issueUpdate',
|
|
102
120
|
actionBy: 'User',
|
|
103
121
|
comment: req.body.comment,
|
|
@@ -127,7 +145,7 @@ export async function InfrastepstoResolve( req, res, next ) {
|
|
|
127
145
|
} );
|
|
128
146
|
}
|
|
129
147
|
|
|
130
|
-
req.body.
|
|
148
|
+
req.body.ticketActivity.push( {
|
|
131
149
|
actionType: 'stepsToResolve',
|
|
132
150
|
actionBy: 'Tango',
|
|
133
151
|
reasons: steptoReslove.map( ( item ) => ( {
|
|
@@ -150,7 +168,7 @@ export async function InfraAlert( req, res, next ) {
|
|
|
150
168
|
if ( req.body.hibernationDays ) {
|
|
151
169
|
req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
|
|
152
170
|
await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
|
|
153
|
-
req.body.
|
|
171
|
+
req.body.ticketActivity.push( {
|
|
154
172
|
actionType: 'statusCheckReply',
|
|
155
173
|
actionBy: 'Tango',
|
|
156
174
|
hibernationDays: req.body.hibernationDays,
|
|
@@ -159,7 +177,7 @@ export async function InfraAlert( req, res, next ) {
|
|
|
159
177
|
} else {
|
|
160
178
|
let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
|
|
161
179
|
let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
|
|
162
|
-
req.body.
|
|
180
|
+
req.body.ticketActivity.push( {
|
|
163
181
|
actionType: 'statusCheck',
|
|
164
182
|
actionBy: 'Tango',
|
|
165
183
|
statusCheckAlertTime: statusCheckAlertTime,
|